[Qt-interest] Accessing a non model dialog
Robert Wood
robert.wood at apostrophe.co.uk
Tue Feb 16 10:15:00 CET 2010
Phil wrote:
> Thank you for reading this.
>
> I'm trying to access the widgets on a non model dialog from outside of the
> non modal class itself. This may sound a little confusing and I hope the
> following code may help explain what I'm trying to achieve.
<snip>
> The question is, how do I access the label from the parent class? I tried
> creating the display pointer in the parent's constructor and then passing it
> to ClassB but that doesn't work.
I *think* this is what someone advised me on recently (I was finding
the same problems) and, with his advise, I did it like this:
rw_widget_dialogue dialogue(this);
if (dialogue.exec() == QDialog::Accepted)
{
this->setText(dialogue.getNewName());
this->setGeometry(dialogue.sendGeometry());
}
Now, my dialogue has accept and reject buttons, so I am not sure whether
this would work if you don't want them.
So, a new dialogue is created and if the OK button is pressed, when the
dialogue closes, if the OK button was pressed, the values I want a
returned by two routines I wrote in the rw_widget_dialogue.
For example:
QString rw_widget_dialogue::getNewName(void)
{
return ui->buttonNameLineEdit->text();
}
Where I return what's in my line edit box on the dialogue box.
Hope I have understood your problem correctly. :~)
Rob
More information about the Qt-interest-old
mailing list