getting data from a Dialog
Hi
I'm using public member-functions to get data from a called Dialog.
Code:
#ifndef A_H
#define A_H
#include <QtGui/QDialog>
namespace Ui {
class a;
}
Q_OBJECT
public:
~a();
protected:
private:
Ui::a *m_ui;
};
#endif // A_H
Calling the Dialog ...
Code:
void Dialog::calla()
{
a x;
x.exec();
ui->a_lineEdit->setText(x.getA());
}
Could someone point me other ways to do this!
Thanks
Re: getting data from a Dialog
I think you have chosen the best way to obtain data from a class; by using a getter function.
However, since you seem to want to synchronize the text in two widgets, you can consider connecting a textChanged() signal from your dialog to the lineEdit's setText() slot. In your case that wouldn't really reduce your code, though.
Re: getting data from a Dialog
And if i want this working the opposite direction?
Let's say i want that objects created from class a get some data from de base class.
This is a constructor issue ... isn'it?
Code:
#include "a.h"
#include "ui_a.h"
m_ui(new Ui::a)
{
m_ui->setupUi(this);
m_ui->label.setText("data from the calling dialog!?!");
}
Re: getting data from a Dialog
read about setter and getter functions. In your case it would be like:
Code:
Q_OBJECT
public:
//...
};
{
// if needed check the content of str
ui->someLineEdit->setText(str);
}
Re: getting data from a Dialog
yess ... but the content of that str is somewhere in other Dialog that called this one.
Am i missing something obvious?
Re: getting data from a Dialog
Quote:
Originally Posted by
graciano
Am i missing something obvious?
Yes ;-)
Code:
void Dialog::calla()
{
a x;
x.setSomeThing("foo bar");
x.exec();
ui->a_lineEdit->setText(x.getA());
}
Re: getting data from a Dialog
Wellll ... guess i need vacations.
"I'll be back :cool:"