main.cpp中的main()函數(shù)負(fù)責(zé)創(chuàng)建mainwindow對(duì)象,調(diào)用show()函數(shù)
#include "mainwindow.h"
#include
int main(int argc, char *argv[])
{
? ? QApplication a(argc, argv);
? ? MainWindow w;
? ? w.show();
? ? return a.exec();
}
在mainwindow.ui中創(chuàng)建組件,拖放到合適的位置,定義屬性、修改重要組件的對(duì)象名
mainwindow.h中#include項(xiàng)目中所有的其他頭文件和其他mainwindow類要用的頭文件,對(duì)枚舉結(jié)構(gòu)體等、mainwindow類中的成員與方法進(jìn)行聲明
mainwindow.cpp中先定義mainwindow的構(gòu)造函數(shù):ui->setup(this);,然后new其他類的對(duì)象,對(duì)需要的變量和組件進(jìn)行初始化,連接所有要連接的信號(hào)與槽
定義所有的槽函數(shù)
定義其他函數(shù)
編寫(xiě)其他的類