06-01-2.cpp

来自「qt实例代码!《24小时学通qt编程》 的代码!不错!已经在qt2.3.7调试o」· C++ 代码 · 共 29 行

CPP
29
字号
#include <qapplication.h>
#include <qwidget.h>
#include <qpushbutton.h>

class MyMainwindow : public QWidget
{
public:
	MyMainwindow();
private:
	QPushButton *b1;
};

MyMainwindow::MyMainwindow()
{
	setGeometry(100, 100, 200, 100);
	b1 = new QPushButton("This is a push button1", this);
	b1->setGeometry(10, 10, 180, 80);
	b1->setFont(QFont("Times", 16, QFont::Bold));
}

int 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 + -
显示快捷键?