用QT创建一个窗口的代码

mywidget1.pro

QT += widgets

SOURCES += \
    main.cpp



#include


int main(int argc,char * argv[])
{
    QApplication a(argc,argv);
    QWidget * widget = new QWidget();
    widget->setWindowTitle(QObject::tr("I'm widget"));
    QLabel * label = new QLabel();
    label->setWindowTitle(QObject::tr("I'm label"));
    label->setText(QObject::tr("label:I'm a window"));
    label->resize(180,20);
    QLabel * label2 = new QLabel(widget);
    label2->setText(QObject::tr("label2:I'm not a dulideWindow,but window's son"));
    label2->resize(250,20);
    label->show();
    widget->show();
    int ret = a.exec();
    delete label;
    delete widget;
    return ret;
}

你可能感兴趣的:(用QT创建一个窗口的代码)