05-01.cpp

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

CPP
39
字号
#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 window1", this);
	b1->setGeometry(10, 10, 180, 80);
	b1->setFont(QFont("Time", 18, QFont::Bold));

	//
	//
	addChild(b1);
}

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