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

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

posted on 2016-01-28 18:03  Soler-He  阅读(148)  评论(0)    收藏  举报

导航