Results 1 to 5 of 5

Thread: move parent window to the front.

  1. #1
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default move parent window to the front.

    I have the following problem I am trying to solve:

    My main window contains an image. In a child dialog that is opened from the main window the user needs to be able to go to the main window and select an area from the image then return control to the child dialog. This is optional and should only happen if the user clicks a button on the child dialog.

    I have setup a signal in the child dialog and a slot in the main window to handle the interaction. But I can't get the main window to come to the front. I have tried using raise() in the main window and also stackUnder(parentWidget (FALSE)) (parentWidget (FALSE) always returns 0 so it is not working) in the child dialog to bring the main window forward. The main window clearly ends up with the focus when the button in the child dialog is clicked but only because I pop up a QMessageBox in the slot that handles the signal emitted by the child dialog but the main window is stuck behind the child dialog. The child dialog is modeless.

    I am using QT3 if that matters.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: move parent window to the front.

    did u try activateWindow() ??

  3. #3
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: move parent window to the front.

    I can't figure out how to use activateWindow() in QT 3 for this. This is not a member of the QDialog class which is what my windows are. In fact in QT 3 it appears that activateWindow() is part of the QWorkspace class. QWorkspace appears to be for doing MDI stuff. My app is not an MDI app and I have no objects that are of QWorkspace class. So I was not even able to figure out how to get this to build when I call activateWindow(). In QT 4 it appears that activateWindow() is part of the QDialog class.

    I have figured out that this is a modality issue that had to do with the way I was instantiating the child dialog. What I was doing was creating the child dialog if a certain button was pushed on the main window and then destroying the dialog when returning control to the main window. What I have learned is that when a dialog is created this way there is no way to make it modeless (IE. it is always modal). What I ended up doing was to instantiate the child dialog during the application startup like this:

    Qt Code:
    1. int main( int argc, char **argv )
    2. {
    3. QApplication a( argc, argv );
    4.  
    5. // create child dialog
    6. ProfileParms profParms;
    7. profParms.setModal(FALSE);
    8. profParms.show();
    9. // hide dialog until needed
    10. profParms.hide();
    11.  
    12. // create main window
    13. lprofMain w;
    14. w.show();
    15.  
    16. // Setup signals and slots connections so that
    17. // main window and child dialog can interact as needed
    18. QObject::connect(&profParms, SIGNAL(signalPickRGB()), &w, SLOT(slotPickRGBPatch()));
    19. QObject::connect(&profParms, SIGNAL(profileParmsOK()), &w, SLOT(slotUpdateProfileParmsText()));
    20. QObject::connect(&w, SIGNAL(showProfileParms()), &profParms, SLOT(slotShow()));
    21.  
    22.  
    23. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    24.  
    25. // Start everything running
    26. return a.exec();
    27. }
    To copy to clipboard, switch view to plain text mode 

    It took me a while to figure this out but it is working.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: move parent window to the front.

    good u solved the problem

    activateWindow is a function of QWidget in Qt 4.2.0 onwards. I am not sure about Qt 3

  5. #5
    Join Date
    Jan 2007
    Posts
    13
    Qt products
    Qt4

    Default Re: move parent window to the front.

    Hi,

    You can use setActiveWindow() in Qt3

    Davit

Similar Threads

  1. ToolWidgets disappear when window inactive
    By Moppel in forum Qt Programming
    Replies: 7
    Last Post: 5th January 2007, 22:50
  2. Replies: 3
    Last Post: 23rd July 2006, 19:02
  3. Move window in Clone Mode
    By ultrabrite in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2006, 19:22
  4. Move child widget along with the parent widget
    By sreedhar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 13:00
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 11:21

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.