1. 程式人生 > >qt creator 安裝

qt creator 安裝

我選擇的版本是qt-opensource-windows-x86-mingw492-5.6.1-1.exe。

一路下一步。ok.

第一個qt小程式

#include "mainwindow.h"
#include <QApplication>
#include<QtWidgets>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);    
    QWidget *widget=new QWidget();//建立一個視窗    
    widget->setWindowTitle(QObject::tr("我是七點十二")); 
   
    QLabel *label=new QLabel();//建立第二個視窗   
    label->setWindowTitle(QObject::tr("我是sun"));   
    label->setText(QObject::tr("label:我是視窗"));   
    label->resize(180,20);    

    QLabel *label2=new QLabel(widget);//建立一個widget子部件    
    label2->setText(QObject::tr("我不是獨立視窗,只是widget子部件"));    
    label2->resize(250,20);    
    label->show();    
    widget->show();    
    int ret=a.exec();    
    delete label;    
    delete widget;    
    return ret;       
    return a.exec();
}

該程式主要說明 視窗 獨立視窗  視窗子部件之間關係