(1)滚动条窗体的构造
(2)widget设置背景色。
这个是本色
Dark是这样的:
只需要一个main函数就可以了。
#include"iconeditor.h" #include<QScrollArea> #include<QApplication> int main(int argc,char *argv[]) { QApplication app(argc,argv); IconEditor *iconEditor=new IconEditor; iconEditor->setIconImage(QImage(":/images/mouse.png")); QScrollArea scrollArea;
//iconEditor是要添加滚动条的窗口部件 scrollArea.setWidget(iconEditor);
//设置背景色的方法。 scrollArea.viewport()->setBackgroundRole(QPalette::Light); scrollArea.viewport()->setAutoFillBackground(true);
//设置窗体标题 scrollArea.setWindowTitle(QObject::tr("Icon Editor")); scrollArea.show(); return app.exec(); }
设置背景色的方法:
//设置背景色的方法。 scrollArea.viewport()->setBackgroundRole(QPalette::Light); scrollArea.viewport()->setAutoFillBackground(true);