Results 1 to 2 of 2

Thread: How to check if QWidget is overlapped by other windows

  1. #1
    Join Date
    Mar 2009
    Location
    Belchatow, Poland
    Posts
    38
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default How to check if QWidget is overlapped by other windows

    The title pretty much says it all.
    I have a QMainWindow which visibility I want to toggle when clicking the tray icon. I'm using this code:
    Qt Code:
    1. if(!getMainWnd()->isVisible()) {
    2. getMainWnd()->show();
    3. getMainWnd()->raise();
    4. getMainWnd()->activateWindow();
    5. } else {
    6. getMainWnd()->hide();
    7. }
    To copy to clipboard, switch view to plain text mode 

    It works pretty well but there's one problem, when my main window is overlapped by other windows and programs, it's still considered visible, so when I click tray icon, it get hidden.

    I want to modify my code to do this:
    1. If window is hidden, show it.
    2. If window is visible (and on top), hide it.
    3. If window is visible but under other windows, raise it.

    Can this be achieved with Qt, or do I have to use WinApi, cause I would really want my code to stay multi-platform.

    PS. Using isWindowActive, doesn't work, cause when I click tray icon, the window looses focus, so isWindowActive always returns false.

  2. #2
    Join Date
    Mar 2009
    Location
    Belchatow, Poland
    Posts
    38
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: How to check if QWidget is overlapped by other windows

    Sorry for double posting, but - anybody?

Similar Threads

  1. Performance problem for overlapped QGraphicsElements
    By santa in forum Qt Programming
    Replies: 1
    Last Post: 3rd August 2010, 19:14
  2. How to use html to show overlapped images in QToolTip
    By LorenLiu in forum Qt Programming
    Replies: 0
    Last Post: 19th April 2010, 08:52
  3. Replies: 0
    Last Post: 1st September 2009, 09:23
  4. Can you hide the titlebar for a Qwidget in Windows?
    By sgmurphy19 in forum Qt Programming
    Replies: 2
    Last Post: 11th February 2008, 21:28
  5. StackedWidget overlapped
    By manucorrales in forum Qt Programming
    Replies: 5
    Last Post: 14th July 2006, 20:18

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
  •  
Qt is a trademark of The Qt Company.