Results 1 to 5 of 5

Thread: How to open QMainWindow object from QDialog object as an active window

  1. #1
    Join Date
    Apr 2011
    Location
    Hyderabad
    Posts
    86
    Thanks
    17
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default How to open QMainWindow object from QDialog object as an active window

    I want to open QMainWindow Object in QDialog Object as an active window or top level window.

    My code is like this :


    connect ((open button on QDialog object)), SIGNAL (clicked()),this , SLOT (openMyForm()));

    void MyDialog:penMyForm()
    {
    myForm = new QMainWindow;
    myForm->show();
    }
    I have even used setActivateWindow() and raise() function call in openMyForm slot but still it's not working.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to open QMainWindow object from QDialog object as an active window

    check these,

    1. Check if the slot is being called
    2. If slot is being called, then it should create a new QMainWindow, check if it not hidden below the QDialog

  3. The following user says thank you to Santosh Reddy for this useful post:

    sanjeet (15th July 2011)

  4. #3
    Join Date
    Apr 2011
    Location
    Hyderabad
    Posts
    86
    Thanks
    17
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to open QMainWindow object from QDialog object as an active window

    Hi Santosh,

    First of all, thanks for replying.
    I have already checked it...
    1. Slot is called and
    2. A new QMainWindow is created below the QDialog.
    But my problem is i want to put this new QMainWindow above the QDialog,(not hidden below the QDialog) when it is created.
    so can you help me.

  5. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to open QMainWindow object from QDialog object as an active window

    I guess you are creating a modal dialog, try this
    Qt Code:
    1. void MyDialog:penMyForm()
    2. {
    3. setModal(false);
    4. myForm = new QMainWindow;
    5. myForm->show();
    6. }
    To copy to clipboard, switch view to plain text mode 

    Update: You can also make dialog as parent of QMainWindow, this way mainwindow till remain on top of dialog

    Qt Code:
    1. void MyDialog:penMyForm()
    2. {
    3. setModal(false);
    4. myForm = new QMainWindow(this);
    5. myForm->show();
    6. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Santosh Reddy; 15th July 2011 at 20:06.

  6. The following user says thank you to Santosh Reddy for this useful post:

    sanjeet (17th July 2011)

  7. #5
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: How to open QMainWindow object from QDialog object as an active window

    Do you show the dialog by calling QDialog::exec()? Use QDialog::show() instead of calling QDialog::exec(). If you want the main window always on top, you can set it as modal (setWindowModality(Qt::WindowModality);
    ~ We are nothing in this universe ~

  8. The following user says thank you to viulskiez for this useful post:

    sanjeet (17th July 2011)

Similar Threads

  1. Replies: 4
    Last Post: 20th August 2010, 14:07
  2. Deleting QDialog object on close
    By ahmdsd_ostora in forum Qt Programming
    Replies: 2
    Last Post: 28th June 2010, 10:55
  3. Replies: 1
    Last Post: 17th May 2010, 11:40
  4. Replies: 1
    Last Post: 28th October 2008, 17:29
  5. Open a QMainWindow Object in QDialog Object
    By chuengchuenghq in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2008, 07:33

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.