QT-----hello world

在.pro文件中添加:

greaterThan(QT_MAJOR_VERSION,4):QT += widgets

main.cpp文件代码

#include<QApplication>
#include<QDialog>
#include<QLabel>

int main(int argc,char *argv[])
{
    QApplication a(argc,argv);
    QDialog w;
    w.resize(400,300);//窗口大小,宽400,高300像素
    QLabel label(&w);
    label.move(120,120);//窗口大小,默认对话框左上角是(0,0)
    //label.setText("hello~~~~~!!");
    label.setText(QObject::tr("hello~~~~~!!"));//国际化方式显示中文
    w.show();
    return a.exec();
}
 

猜你喜欢

转载自blog.csdn.net/IT8343/article/details/81531132