[Qt-interest] Accessing a non model dialog
Phil
phillor at telstra.com
Wed Feb 17 02:26:15 CET 2010
On Tue, 16 Feb 2010 07:15:00 pm Robert Wood wrote:
> 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.
>
Thank you Rob for taking the time to answer my question. I didn't explain
the problem very well and so your answer didn't relate to my question; my
fault entirely. Nevertheless I have filled your reply away for future
reference.
I have now solved the problem but as often happens I don't know if my
method is technically correct.
--
Regards,
Phil
More information about the Qt-interest-old
mailing list