您的位置:首页 > 编程语言 > Qt开发

转《Qt教程一 —— 第四章:使用窗口部件》

2016-01-28 18:03 381 查看
本次内容均转自 http://www.cppblog.com/lai3d/archive/2007/07/21/28477.html
/****************************************************************
**
** Qt教程一 - 4
**
****************************************************************/

#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>

class MyWidget : public QWidget
{
public:
MyWidget( QWidget *parent=0, Qt::WindowFlags f = 0 );
};

MyWidget::MyWidget( QWidget *parent, Qt::WindowFlags f )
: QWidget( parent, f )
{
setMinimumSize( 200, 120 );
setMaximumSize( 200, 120 );

QPushButton *quit = new QPushButton( "Quit", this );
quit->setGeometry( 62, 40, 75, 30 );
quit->setFont( QFont( "Times", 18, QFont::Bold ) );

connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) );
}

int main( int argc, char **argv )
{
QApplication a( argc, argv );

MyWidget w;
w.setGeometry( 100, 100, 200, 120 );
w.show();
return a.exec();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: