Results 1 to 3 of 3

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

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Can't launch a new instance of a dialog-widget from inside it.

    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can't launch a new instance of a dialog-widget from inside it.

    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.

  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't launch a new instance of a dialog-widget from inside it.

    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.

    Qt Code:
    1. do_things(QWidget *w )
    2. {
    3. QWidget * top_parent;
    4. top_parent=w;
    5. do { top_parent=top_parent->parentWidget() ; }
    6. while (top_parent->parentWidget()!=0);
    7. }
    To copy to clipboard, switch view to plain text mode 
    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...

Similar Threads

  1. Qt Designer Size of table widget inside Tab Widget is not flexible.
    By akash in forum Qt Tools
    Replies: 2
    Last Post: 14th September 2011, 11:45
  2. Replies: 8
    Last Post: 28th June 2011, 14:57
  3. QMainWindow inside another widget
    By DanFessler in forum Newbie
    Replies: 4
    Last Post: 23rd August 2010, 21:58
  4. How to launch a dialog?
    By rakkar in forum Newbie
    Replies: 2
    Last Post: 25th August 2009, 17:20
  5. new instance of dialog
    By gemidjy in forum Qt Programming
    Replies: 3
    Last Post: 28th February 2008, 17:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.