Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] How to remove application's button from taskbar (for minimizing to tray) with Qt 5?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to remove application's button from taskbar (for minimizing to tray) with Qt 5?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on 31 Dec 2012, 23:04 last edited by
    #1

    I used to have this piece of code for removing from taskbar (with Qt 4, CMainWindow is subclass of QmainWindow):

    @void CMainWindow::hideEvent(QHideEvent* pEvent)
    {
    QWidget::hideEvent(pEvent);
    if(isMinimized())
    QTimer::singleShot(0, this, SLOT(hide()));
    }@

    It worked, but only on Windows. Now, after transition to Qt 5, it doesn't work at all - hideEvent is only called when application is closed.
    How to do it properly?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on 1 Jan 2013, 15:05 last edited by
      #2

      I think minimizing a Window does not really "hide" it, so it won't trigger a hideEvent().

      Better use changeEvent(QEvent *event) and check for an event of type QEvent::WindowStateChange.

      bq. QEvent::WindowStateChange - The window's state (minimized, maximized or full-screen) has changed.

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • H Offline
        H Offline
        HIskind
        wrote on 1 Jan 2013, 15:20 last edited by
        #3

        This can help:
        @
        bool CMainWindow::event(QEvent* e) {
        bool result = QWidget::event(e);
        if(isMinimized())
        QTimer::singleShot(0, this, SLOT(hide()));
        return result;
        }
        @

        1 Reply Last reply
        0
        • V Offline
          V Offline
          Violet Giraffe
          wrote on 1 Jan 2013, 19:50 last edited by
          #4

          Thanks! Has to be like this:

          @bool CMainWindow::event(QEvent* e)
          {
          bool result = QWidget::event(e);
          if(e->type() == QEvent::WindowStateChange && isMinimized())
          QTimer::singleShot(0, this, SLOT(hide()));
          return result;
          }@

          Then it works as intended.

          1 Reply Last reply
          0

          1/4

          31 Dec 2012, 23:04

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved