Results 1 to 3 of 3

Thread: Bring window to the front

  1. #1
    Join Date
    Feb 2009
    Posts
    21
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Bring window to the front

    Hi,

    How do I ensure that a window displays on top of any other windows on the desktop?

    This is how I display a window now -

    this->setGeometry(QApplication::desktop()->availableGeometry(1)); this->showFullScreen();

    Thanks,

    Barry.

  2. #2
    Join Date
    Jul 2008
    Location
    London, UK
    Posts
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Bring window to the front

    QWidget::raise() or QMainWindow::activateWindow.

    ActivateWindow is probably what you want but it will have "odd" effects on Windows boxes as if the app window isn't on top you'll get a "flasher" in the task bar instead. That is it won't actually raise the window to the top but show the user that the application requires attention.

    The other trick might be to set the "Qt::WindowStaysOnTopHint" attribute on the window. e.g. p_mainWindow->setAttribute(Qt::WindowStaysOnTopHint);

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

    Barry79 (14th August 2009)

  4. #3
    Join Date
    Jun 2007
    Location
    Massachusetts, USA
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Bring window to the front

    I found that this problem is a windows manager problem rather than just Qt. The windows manager handles all windows, but your application can only affect its own windows. My project focuses on X11, where I always found "Qt::WindowStaysOnTopHint" was a hint only, and ignored by the windows manager. I was able to control the windows of my own application to assure that an important one stayed on top of others in the application, but even this was roundabout. I added an eventFilter on all widgets with actions that might cause the windows manager to raise a window to the top. If the event was something like "MouseButtonRelease", I'd queue another event to check on the window layering. When Qt and the windows manager are all done, my new event comes up and I simply "raise" the window I want on top. (If anyone has simpler ideas, I'd love to hear.) Now if you want to keep your application window on top of windows that are not part of your application, I don't know what to do with that!

    - Dick

Similar Threads

  1. Bring application window to front
    By St@n in forum Qt Programming
    Replies: 13
    Last Post: 5th July 2019, 02:55
  2. Replies: 2
    Last Post: 9th August 2009, 23:08
  3. Bring QDialog to front
    By mitro in forum Newbie
    Replies: 3
    Last Post: 21st April 2008, 21:32
  4. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 09:41
  5. Replies: 5
    Last Post: 5th August 2006, 00:44

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.