嵌入式软件工程师&&太极拳
全部博文(548)
分类:
2011-02-23 00:00:06
这个是一个从一个对话框得到另一个对话框信息的qt例子(只有主要程序)
[myqq.h]
#ifndef MYQQ_H
#define MYQQ_H
#include
#include "ui_myqq.h"
#include
#include "qqqq.h"
class myqq : public QMainWindow
{
Q_OBJECT
public:
myqq(QWidget *parent = 0, Qt::WFlags flags = 0);
~myqq();
private:
Ui::myqqClass ui;
public:
qqqq *a;
QPushButton *b;
public slots:
void q_show();
};
#endif // MYQQ_H
----------------------------------------------------------
[main.cpp]
#include "myqq.h"
#include
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
myqq w;
w.show();
return a.exec();
}
-----------------------------------------------------------
[myqq.cpp]
#include "myqq.h"
#include "qqqq.h"
#include
myqq::myqq(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
b = new QPushButton(this);
connect(b, SIGNAL(clicked()), this, SLOT(q_show()));
a = new qqqq();
// a->getname(ui.comboBox->currentText());
}
myqq::~myqq()
{
}
void myqq::q_show()
{
QString name = ui.comboBox->currentText();
qDebug() << ("QDebug << %s", name);
// qqqq w; //获得事件
// w.getname(name);
// w.exec();
a->getname(name);
a->exec();
}
--------------------------------------------------------------
[qqqq.h]
#ifndef QQQQ_H
#define QQQQ_H
#include
#include "ui_qqqq.h"
class qqqq : public QDialog
{
Q_OBJECT
public:
qqqq(QWidget *parent = 0);
~qqqq();
private:
Ui::qqqqClass ui;
// QLabel *label;
public:
void getname(QString name);
};
#endif // QQQQ_H
--------------------------------------------------------------
[qqqq.cpp ]
#include "qqqq.h"
#include "myqq.h"
qqqq::qqqq(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
//ui.lineEdit->setText(myqq::comboBox->currentText());
//printf("name = %s\n", name);
// getname("Hello");
//label = new QLabel(this);
// label->setText("Hello");
}
qqqq::~qqqq()
{
}
void qqqq::getname(QString name)
{
ui.label->setText(name);
}
---------------------------------------------------------------