Windows编程

    xiaoxiao2021-03-25  72

    纯代码编写程序:

    首先要添加一行代码:

    greaterThan(QT_MAJOR_VERSION,4):QT+=widgets

    源代码:

    #include<QApplication>

    #include<QDialog>

    #include<QLabel>

    int main(int argc,char *argv[]);

    {

    QApplication a(argc.argv);

    QDIalog w;

    QLabel label(&w);

    label.setText("Hello World!你好Qt!");

    w.show();

    return a.exec();

    }

    前三行是头文件包含。

    若窗口太小,可更改代码为:

    #include<QApplication>

    #include<QDialog>

    #include<QLabel>

    int main(int argc,char *argv[]);

    {

    QApplication a(argc.argv);

    QDIalog w;

    w.resize(400,300);

    QLabel label(&w);

    label.move(120,120);

    label.setText("Hello World!你好Qt!");

    w.show();

    return a.exec();

    }

    转载请注明原文地址: https://ju.6miu.com/read-37794.html

    最新回复(0)