PDA

View Full Version : Can't launch a new instance of a dialog-widget from inside it.



tonnot
20th September 2011, 20:15
Maybe it can't be done....
I have a Widget-dialog based. Depending of a parameter I show a Qframe or another.
I can create two instances of this from the main window but I can't show an instance of 'myself' ....
I dont see anything or the dialog close itself....

The initial dialog is modal, showed from mainwindow with 'exec()'.

This is pseudo code for MY_WIDGET class.
I have a private var :
MY_WIDGET * my_instance_of_myself ; ( because i'm going to make some conection later )

I have a pushbutton click with:
my_instance_of_myself = new MY_WIDGET("the_option_i_want");
my_instance_of_myself.exec(); - this one shows an empty dialog.
my_instance_of_myself.show(); - this one 'auto-close' the initial dialog

Any quick idea to solve this ?
Thanks

ChrisW67
20th September 2011, 21:22
Any quick idea to solve this ?
Post the code because "this one shows an empty dialog" is a direct consequence of the code in MY_WIDGET.

tonnot
21st September 2011, 09:01
Solved:
An initial problem was the next:
As I wrote, depending on some parametersI show one or another Qframe.
I have 'do_things' function, that receive the frame I want to use as main widget
Inside this function I search the top_parent, to move my frame to there. By last, I adjust the size of the top_parent to the Qframe choosed.


do_things(QWidget *w )
{
QWidget * top_parent;
top_parent=w;
do { top_parent=top_parent->parentWidget() ; }
while (top_parent->parentWidget()!=0);
}

The problem was originated by the create method I use, I was passing the my_widget first instantiated as a parent of the second.
The top_parent detected in this second case was the parent of the first instance not the actual.

Thanks...