最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Qt之ui在程序中的使用-多繼承法介紹

 更新時(shí)間:2012年11月13日 11:35:44   作者:  
本文將介紹Qt之ui在程序中的使用-多繼承法,需要的朋友可以參考
thirdDialog.h
復(fù)制代碼 代碼如下:

#ifndef THIRDDIALOG_H
#define THIRDDIALOG_H
#include <QtGui>
#include "ui_third.h"
class thirdDialog:public QDialog,private Ui::Third
{
Q_OBJECT
public:
thirdDialog(QWidget *parent=0);
~thirdDialog();
};
#endif

thirdDialog.cpp
#include "thirdDialog.h"
thirdDialog::thirdDialog(QWidget *parent)
{
setupUi(this);
}
thirdDialog::~thirdDialog()
{
}

maindialog.h
復(fù)制代碼 代碼如下:

#ifndef MAINDIALOG_H
#define MAINDIALOG_H
#include <QtGui>
#include "ui_first.h"
#include "ui_second.h"
#include "thirdDialog.h"

class MainDialog : public QDialog
{
Q_OBJECT
public:
MainDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
~MainDialog();
private:
Ui::First firstUi;
Ui::Second secondUi;
private slots:
void on_btnChild_clicked();
};
#endif // MAINDIALOG_H

maindialog.cpp
復(fù)制代碼 代碼如下:

#include "maindialog.h"
MainDialog::MainDialog(QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags)
{
QTabWidget *tabWidget = new QTabWidget(this);
QDialog *w1 = new QDialog;
firstUi.setupUi(w1);
QWidget *w2 = new QWidget;
secondUi.setupUi(w2);
tabWidget->addTab(w1,tr("First Tab"));
tabWidget->addTab(w2,tr("Second Tab"));
tabWidget->resize(300,300);
connect(firstUi.btnClose,SIGNAL(clicked()),this,SLOT(close()));
connect(secondUi.btnChild,SIGNAL(clicked()),this,SLOT(on_btnChild_clicked()));
}
MainDialog::~MainDialog()
{
}
void MainDialog::on_btnChild_clicked()
{
thirdDialog *dlg = new thirdDialog;
dlg->exec();
}

分析:
多繼承方式可直接對ui界面上的控件或函數(shù)進(jìn)行操作,代碼編寫更簡潔;
而是用單繼承方式,在操作ui頁面上的控件時(shí)需加上ui對象前綴,編寫代碼較為麻煩。
但,對于程序中所需ui頁面較多時(shí),使用單繼承法則要靈活的多。。

相關(guān)文章

最新評論

台东市| 环江| 百色市| 隆化县| 若羌县| 水城县| 色达县| 苍南县| 体育| 志丹县| 咸丰县| 太保市| 龙口市| 昌江| 隆安县| 浦北县| 通化市| 沙洋县| 华阴市| 莱阳市| 城口县| 博湖县| 金门县| 新野县| 师宗县| 喀喇| 乾安县| 安庆市| 大邑县| 铁力市| 新泰市| 淮滨县| 全州县| 册亨县| 合作市| 伊金霍洛旗| 河南省| 措美县| 蒲城县| 昭苏县| 香格里拉县|