【QT 5】最初のハローワールドプログラム

1245 ワード

#include 

#include 
#include 

int main(int argc,char* argv[]){
    QApplication app(argc,argv);
    QWidget w;

    QPushButton button;
    button.setText("Button");
    button.setParent(&w);

    QObject::connect(&button,SIGNAL(clicked()),&w,SLOT(close()));

    w.setWindowTitle("hello world");
    w.show();
    return app.exec();
}

QWidgetを使用するには.ProファイルにQT+=widgets guiを追加
ここでwはメインウィンドウを示す.
転載先:https://www.cnblogs.com/tao-zhu-forever/p/9556809.html