5_1.cpp

来自「一个qt设计的教程」· C++ 代码 · 共 35 行

CPP
35
字号
#include <qapplication.h>#include <qpushbutton.h>#include <qfont.h>#include <qscrollview.h>class MyMainWindow:public QScrollView{ public:    MyMainWindow(); private:    QPushButton *b1;};MyMainWindow::MyMainWindow(){ setGeometry(100,100,200,100);  b1 = new QPushButton("This button is not too\n big for the window!",this); b1->setGeometry(10,10,180,80); b1->setFont(QFont("Times",18,QFont::Bold)); //we must call the QScrollView::addChild function for each of its child widgets. addChild(b1);}main(int argc,char **argv){ QApplication a(argc,argv); MyMainWindow w; a.setMainWidget(&w); w.show(); a.exec();}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?