Sending QString to Dialog from MainWindow
General and Desktop
7
Posts
4
Posters
2.5k
Views
1
Watching
-
Either modify the constructor of the dialog to accept additional parameter or add a setter method to your dialog class.
-
You can modify constructor like this:
@Dialog ::Dialog (QWidget *parent, QString text) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
ui->label->setText(text);
}@
don't forget set default value for text in *.h file
and
@Dialog text(this, someText);
test.exec();@or you can add new method for settings text:
@void Dialog::setLabelText(QString value)
{
ui->label->setText(value);
}@ -
It should rather be:
@
Dialog ::Dialog (QString text, QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
ui->label->setText(text);
}
@to follow Qt's pattern