#include "happydraw.h"
const int InsertTextItemButton = 10;
const int InsertProxyItemButton = 11;
const int InsertPixmapItemButton = 12;
const int InsertPenItemButton = 13;
happyDraw::happyDraw(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
mainWidget = new QWidget();
mainVlay = new QVBoxLayout();
// 标题
myTitleBar* titleBar = new myTitleBar(this);
titleBar->addTypeButton(myTitleBar::LOCK);
titleBar->addTypeButton(myTitleBar::DEFAULT);
titleBar->setText(tr("Qt Happy Draw"));
mainVlay->addWidget(titleBar);
// 菜单
m_menuBar = new myMenuBar(this);
mainVlay->addWidget(m_menuBar);
// 工具栏
mainHlay = new QHBoxLayout();
setupTextActions();
createOtherActions();
createMenus();
createToolBar();
createToolBox();
createScene();
loadFile("qss/myNewQss.qss");
mainVlay->addLayout(mainHlay);
mainWidget->setLayout(mainVlay);
setCentralWidget(mainWidget);
resize(800,600);
showMaximized ();
setWindowFlags(Qt::FramelessWindowHint | Qt::CustomizeWindowHint);
connect(titleBar,SIGNAL(sig_close()),this,SLOT(close()));
}
happyDraw::~happyDraw()
{
}
void happyDraw::setupTextActions()
{
QMenu *menu = new QMenu(tr("F&ormat"), this);
m_menuBar->addMenu(menu);
fontFormatBar = new myToolBar(this);
fontFormatBar->setIconSize(QSize(20,20));
fontFormatBar->setWindowTitle(tr("Format Actions"));
mainVlay->addWidget(fontFormatBar);
// 粗体
actionTextBold = new QAction(QIcon(":/Resources/textbold.png"), tr("&Bold"), this);
actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B);
QFont bold;
bold.setBold(true);
actionTextBold->setFont(bold);
connect(actionTextBold, SIGNAL(triggered()), this, SLOT(handleFontChange()));
fontFormatBar->addAction(actionTextBold);
menu->addAction(actionTextBold);
actionTextBold->setCheckable(true);
// 斜体
actionTextItalic = new QAction(QIcon(":/Resources/textitalic.png"), tr("&Italic"), this);
actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I);
QFont italic;
italic.setItalic(true);
actionTextItalic->setFont(italic);
connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(handleFontChange()));
fontFormatBar->addAction(actionTextItalic);
menu->addAction(actionTextItalic);
actionTextItalic->setCheckable(true);
// 下划线
actionTextUnderline = new QAction(QIcon(":/Resources/textunder.png"), tr("&Underline"), this);
actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U);
QFont underline;
underline.setUnderline(true);
actionTextUnderline->setFont(underline);
connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(handleFontChange()));
fontFormatBar->addAction(actionTextUnderline);
menu->addAction(actionTextUnderline);
actionTextUnderline->setCheckable(true);
// 字型
QLabel *lab_style = new QLabel;
lab_style->setText(tr("font style"));
fontFormatBar->addWidget(lab_style);
comboFont = new QFontComboBox(fontFormatBar);
comboFont->setMinimumSize(100,20);
fontFormatBar->addWidget(comboFont);
connect(comboFont, SIGNAL(activated(const QString &)),
this, SLOT(handleFontChange()));
// 字体大小
QLabel *lab_size = new QLabel;
lab_size->setText(tr("point size"));
fontFormatBar->addWidget(lab_size);
fontSizeCombo = new QComboBox(fontFormatBar);
fontSizeCombo->setMinimumSize(50,20);
fontFormatBar->addWidget(fontSizeCombo);
fontSizeCombo->setEditable(true);
for (int i = 8; i < 120; i = i + 2)
fontSizeCombo->addItem(QString().setNum(i));
QIntValidator *validator = new QIntValidator(2, 500, this);
fontSizeCombo->setValidator(validator);
fontSizeCombo->setCurrentIndex(7);
connect(fontSizeCombo, SIGNAL(currentIndexChanged(const QString &)),
this, SLOT(handleFontChange()));
// 字体缩放
QLabel *lab_scale = new QLabel;
lab_scale->setText(tr("font Scale"));
fontFormatBar->addWidget(lab_scale);
fontScaleEdit = new QLineEdit;
fontScaleEdit->setFixedSize(50,20);
fontFormatBar->addWidget(fontScaleEdit);
fontScaleEdit->setContextMenuPolicy(Qt::NoContextMenu);
QRegExp regx("[%0-9]+$");
QValidator *textValidator = new QRegExpValidator(regx, this );
fontScaleEdit->setValidator(textValidator);
fontScaleEdit->setText("100%");
connect(fontScaleEdit,SIGNAL(returnPressed( )),this,SLOT(slot_fontScale( )));
// 颜色
QLabel *lab_color = new QLabel;
lab_color->setText(tr("color"));
fontFormatBar->addWidget(lab_color);
QPixmap pix(16, 16);
pix.fill(Qt::black);
actionTextColor = new QAction(pix, tr("&Color..."), this);
connect(actionTextColor, SIGNAL(triggered()), this, SLOT(changeColor()));
fontFormatBar->addAction(actionTextColor);
menu->addAction(actionTextColor);
menu->addSeparator();
//////////////////////////////////////////////////////////////////////////////
// 段落
paragraphBar = new myToolBar(this);
paragraphBar->setIconSize(QSize(20,20));
paragraphBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
paragraphBar->setWindowTitle(tr("Format Actions"));
addToolBarBreak(Qt::TopToolBarArea);
mainVlay->addWidget(paragraphBar);
QActionGroup *grp = new QActionGroup(this);
connect(grp, SIGNAL(triggered(QAction *)), this, SLOT(textAlign(QAction *)));
// 左对齐
actionAlignLeft = new QAction(QIcon(":/Resources/textleft.png"), tr("&Left"), grp);
actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L);
actionAlignLeft->setCheckable(true);
actionAlignLeft->setChecked(true);
// 居中对齐
actionAlignCenter = new QAction(QIcon(":/Resources/textcenter.png"), tr("C&enter"), grp);
actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E);
actionAlignCenter->setCheckable(true);
// 右对齐
actionAlignRight = new QAction(QIcon(":/Resources/textright.png"), tr("&Right"), grp);
actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R);
actionAlignRight->setCheckable(true);
// 分散对齐
actionAlignJustify = new QAction(QIcon(":/Resources/textjustify.png"), tr("&Justify"), grp);
actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J);
actionAlignJustify->setCheckable(true);
paragraphBar->addActions(grp->actions());
menu->addActions(grp->actions());
menu->addSeparator();
}
void happyDraw::createToolBox()
{
graphicsBox = new QToolBox;
graphicsBox->resize(300,500);
graphicsBox->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Ignored));
mainHlay->addWidget(graphicsBox);
textBtn1 = new QToolButton;
textBtn1->setFixedSize(50,50);
textBtn1->setCheckable(true);
textBtn1->setText(tr("static text"));
//textBtn1->hide();
textBtn2 = new QToolButton;
textBtn2->setFixedSize(50,50);
textBtn2->setCheckable(true);
textBtn2->setText(tr("rolling text"));
//textBtn2->hide();
btn_shapeRect = new QToolButton;
btn_shapeRect->setFixedSize(50,50);
btn_shapeRect->setCheckable(true);
btn_shapeRect->setText(tr("shape rect"));
btn_shapeCircle = new QToolButton;
btn_shapeCircle->setFixedSize(50,50);
btn_shapeCircle->setCheckable(true);
btn_shapeCircle->setText(tr("shape circle"));
btn_shapeTriangle = new QToolButton;
btn_shapeTriangle->setFixedSize(50,50);
btn_shapeTriangle->setCheckable(true);
btn_shapeTriangle->setText(tr("shape triangle"));
btn_shapeStar = new QToolButton;
btn_shapeStar->setFixedSize(50,50);
btn_shapeStar->setCheckable(true);
btn_shapeStar->setText(tr("shape star"));
btn_pixmap = new QToolButton;
btn_pixmap->setFixedSize(50,50);
btn_pixmap->setCheckable(true);
btn_pixmap->setText(tr("pixmap"));
btn_pen = new QToolButton;
btn_pen->setFixedSize(50,50);
btn_pen->setCheckable(true);
btn_pen->setText(tr("pen"));
btnGroup1 = new QButtonGroup;
btnGroup1->setExclusive(false);
btnGroup1->addButton(textBtn1,InsertTextItemButton);
btnGroup1->addButton(textBtn2,InsertProxyItemButton);
btnGroup1->addButton(btn_shapeRect,0);
btnGroup1->addButton(btn_shapeCircle,1);
btnGroup1->addButton(btn_shapeTriangle,2);
btnGroup1->addButto
没有合适的资源?快使用搜索试试~ 我知道了~
happyDraw(new).rar_HappyDraw_qt custom_qt 绘
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共77个文件
png:36个
cpp:18个
h:17个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 118 浏览量
2022-09-22
20:46:01
上传
评论
收藏 114KB RAR 举报
温馨提示
基于 vc2005 和 Qt 开发..有三角形.四边形..五角星..和文字的绘制..结何qt的例子做了一些自定义的东东..
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 77 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/3542a6830a364bf6a0adb34bfd72ce9d_weixin_42662605.jpg!1)
APei
- 粉丝: 65
- 资源: 1万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)