Results 1 to 4 of 4

Thread: Minimize to Tray

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Minimize to Tray

    I have searched all around and cannot get this to work! Attempting to call hide() within changeEvent in a way such as:

    Qt Code:
    1. void AppWindow::changeEvent(QEvent *event)
    2. {
    3. if (event->type() == QEvent::WindowStateChange)
    4. if(isMinimized())
    5. {
    6. hide();
    7. }
    8. QMainWindow::changeEvent(event);
    9. }
    To copy to clipboard, switch view to plain text mode 

    causes the window to white-out rather than hide. Does anyone know why this happens or how to fix this? I am attempting to use a tray-icon on minimize, but without being able to hide will never have much success. Currently, the only way I can work around this is to use a singleShot timer to call the hide.

  2. #2
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Minimize to Tray

    Try this way (at least it works fine in our projects):
    Qt Code:
    1. if (event->type() == QEvent::WindowStateChange && windowState() & Qt::WindowMinimized)
    2. QMetaObject::invokeMethod(this, "hide", Qt::QueuedConnection);
    To copy to clipboard, switch view to plain text mode 
    Oleg Shparber

Similar Threads

  1. Help about a problem on the tray...
    By Bong.Da.City in forum Qt Programming
    Replies: 5
    Last Post: 19th August 2010, 07:33
  2. Minimize to system tray
    By aLiNuSh in forum Newbie
    Replies: 17
    Last Post: 4th March 2010, 12:51
  3. Minimize to system tray
    By krivenok in forum Qt Programming
    Replies: 5
    Last Post: 13th January 2009, 04:34
  4. Tray Ballon
    By eu.x in forum Newbie
    Replies: 5
    Last Post: 28th February 2007, 12:00
  5. QT4/QP Tray Icon
    By incapacitant in forum Newbie
    Replies: 12
    Last Post: 7th June 2006, 18:47

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.