效果图显示
![在这里插入图片描述](https://img-blog.csdnimg.cn/2019120316482284.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0FsdmluX3p5,size_16,color_FFFFFF,t_70)
部分代码
ImageProcessor::ImageProcessor(QWidget *parent)
: QMainWindow(parent)
{
setWindowTitle(tr("Image Processor"));
showWidget =new ShowWidget(this);
setCentralWidget(showWidget);
fontLabel1 =new QLabel(tr("字体:"));
fontComBox =new QFontComboBox;
fontComBox->setFontFilters(QFontComboBox::ScalableFonts);
fontLabel2 =new QLabel(tr("字号:"));
sizeComBox =new QComboBox;
QFontDatabase db;
foreach(int size,db.standardSizes())
sizeComBox->addItem(QString::number(size));
boldBtn =new QToolButton;
boldBtn->setIcon(QIcon("F:/project/qt/demo1/picture/bold.png"));
boldBtn->setCheckable(true);
italicBtn =new QToolButton;
italicBtn->setIcon(QIcon("F:/project/qt/demo1/picture/italic.png"));
italicBtn->setCheckable(true);
underlineBtn =new QToolButton;
underlineBtn->setIcon(QIcon("F:/project/qt/demo1/picture/underline.png"));
underlineBtn->setCheckable(true);
colorBtn =new QToolButton;
colorBtn->setIcon(QIcon("F:/project/qt/demo1/picture/color.png"));
colorBtn->setCheckable(true);
createActions();
createMenus();
createToolBars();
if(img.load("F:/project/qt/demo1/picture/image.png"))
{
showWidget->imageLabel->setPixmap(QPixmap::fromImage(img));
}
connect(fontComBox,SIGNAL(activated(QString)),
this,SLOT(ShowFontComboBox(QString)));
connect(sizeComBox,SIGNAL(activated(QString)),
this,SLOT(ShowSizeSpinBox(QString)));
connect(boldBtn,SIGNAL(clicked()),this,SLOT(ShowBoldBtn()));
connect(italicBtn,SIGNAL(clicked()),this,SLOT(ShowItalicBtn()));
connect(underlineBtn,SIGNAL(clicked()),this,SLOT(ShowUnderlineBtn()));
connect(colorBtn,SIGNAL(clicked()),this,SLOT(ShowColorBtn()));
connect(showWidget->text,SIGNAL(currentCharFormatChanged(QTextCharFormat&)),
this,SLOT(ShowCurrentFormatChanged(QTextCharFormat&)));
connect(showWidget->text->document(),SIGNAL(undoAvailable(bool)),
redoAction,SLOT(setEnabled(bool)));
connect(showWidget->text->document(),SIGNAL(redoAvailable(bool)),
redoAction,SLOT(setEnabled(bool)));
connect(showWidget->text,SIGNAL(cursorPositionChanged()),
this,SLOT(ShowCursorPositionChanged()));
}