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] minimize event
QtWS25 Last Chance

[solved] minimize event

Scheduled Pinned Locked Moved General and Desktop
17 Posts 5 Posters 18.1k Views
  • 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.
  • L Offline
    L Offline
    lgeyer
    wrote on 1 Oct 2012, 04:42 last edited by
    #8

    So, what have you tried? How does the code look like? What did you expect? And what is it actually doing?

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      zidom
      wrote on 1 Oct 2012, 06:33 last edited by
      #9

      I tried this
      @
      int main(int argc, char *argv[])
      {
      QApplication application(argc, argv);

      QWidget widget;
      QMainWindow mainWindow(&widget);
      
      mainWindow.show();
      
      return application.exec();
      

      }
      @
      but it doesn't hide the taskbar icon hides the window to
      and when i tried this
      @int main(int argc, char *argv[])
      {
      QApplication application(argc, argv);

      QMainWindow mainWindow;
      
      mainWindow.show();
      
      ShowWindow(mainWindow.winId(), SW_HIDE);
      SetWindowLong(mainWindow.winId(), GWL_EXSTYLE, GetWindowLong(mainWindow.winId(), GWL_EXSTYLE) | ~WS_EX_APPWINDOW);
      ShowWindow(mainWindow.winId(), SW_SHOW);
      
      return application.exec();
      

      }@
      i received some errors

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on 1 Oct 2012, 07:38 last edited by
        #10

        Snippet #1 does not show a taskbar icon, and so does setting the Qt::Tool window flag - at least for me.
        @
        void MainWindow::changeEvent(QEvent *event)
        {
        if (event->type() == QEvent::WindowStateChange)
        {
        if (isMinimized() == true)
        setWindowFlags(windowFlags() | Qt::Tool);
        else
        setWindowFlags(windowFlags() & ~Qt::Tool);
        }

        return QMainWindow::changeEvent(event);
        

        }@

        Using ~WS_EX_APPWINDOW does, as mentioned in the linked thread, not work properly.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          shs_night
          wrote on 1 Oct 2012, 12:13 last edited by
          #11

          [quote author="zidom" date="1348914755"]hi i wrote a program i want to hide and sent it to tray when its minimized i used code below
          @bool myclass::event(QEvent *event)
          {
          if (event->type()==QEvent::WindowStateChange && isMinimized())
          {
          hide();
          event->ignore();
          }
          else{
          return QMainWindow::event(event);}
          }@
          [/quote]

          hi

          @if (event->type()==QEvent::WindowStateChange && isMinimized())
          {
          hide();
          show();
          hide();
          event->ignore();
          }
          else{
          return QMainWindow::event(event);}@

          QtSDK 1.2 + MinGW + Desktop !

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zidom
            wrote on 1 Oct 2012, 12:28 last edited by
            #12

            Hi mahdi
            Thanks that worked but i don't understand why i should hide then show then hide again
            im iranian like you :D

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zidom
              wrote on 1 Oct 2012, 12:34 last edited by VRonin 4 Apr 2017, 14:35
              #13

              bq.

               void MainWindow::changeEvent(QEvent *event)
              {
                  if (event->type() == QEvent::WindowStateChange)
                  {
                      if (isMinimized() == true)
                          setWindowFlags(windowFlags() | Qt::Tool);
                      else
                          setWindowFlags(windowFlags() & ~Qt::Tool);
                  }
               
                  return QMainWindow::changeEvent(event);
              }
              

              I used that it works for hiding but when i want to show the form again

              void myclass::trayicon_click(QSystemTrayIcon::ActivationReason reason)
              {
                  if(reason==QSystemTrayIcon::Trigger)
                  {
                      show();
                  }
              }
              

              it looks like this when i show the form !http://dl.2rialy.ir/ZiDoM-Ups/91/after.JPG(show)!

              1 Reply Last reply
              0
              • B Offline
                B Offline
                broadpeak
                wrote on 1 Oct 2012, 12:59 last edited by
                #14

                This example may help you:
                http://doc.qt.digia.com/4.7-snapshot/desktop-systray.html
                (void Window::closeEvent(QCloseEvent *event))

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  lgeyer
                  wrote on 1 Oct 2012, 16:23 last edited by
                  #15

                  Use showNormal() instead.

                  1 Reply Last reply
                  0
                  • Z Offline
                    Z Offline
                    zidom
                    wrote on 1 Oct 2012, 18:04 last edited by
                    #16

                    bq. This example may help you:
                    http://doc.qt.digia.com/4.7-snapshot/desktop-systray.html
                    (void Window::closeEvent(QCloseEvent *event))

                    I already saw that but that doesn't help me by the way thank

                    bq. Use showNormal() instead.

                    thanks a lot that worked again thanks for following this article and helping me

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      lgeyer
                      wrote on 1 Oct 2012, 18:35 last edited by
                      #17

                      You're welcome.

                      Feel free to prepend the thread title with [Solved] (just edit your initial post) to indicate that there is a solution inside.

                      1 Reply Last reply
                      0

                      17/17

                      1 Oct 2012, 18:35

                      • Login

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