本次内容均转自 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();
}