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
Forum Updated to NodeBB v4.3 + New Features

[solved] minimize event

Scheduled Pinned Locked Moved General and Desktop
17 Posts 5 Posters 18.5k 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.
  • D Offline
    D Offline
    DerManu
    wrote on last edited by
    #2

    What happens when you let the event propagate to the mainwindow in both cases? (I.e. remove the event->ignore(); and the else branch)

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      zidom
      wrote on last edited by
      #3

      no difference it same as now i test that before

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #4

        Well, if you minimize a window it is automatically hidden (that's why you minimize it in the first place).

        If you are talking about hiding the taskbar entry see "this":http://qt-project.org/forums/viewthread/8902 thread.

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          zidom
          wrote on last edited by
          #5

          those dont work to

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lgeyer
            wrote on last edited by
            #6

            How much use do you think can we make of "those dont work to"?

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zidom
              wrote on last edited by
              #7

              sorry but i thought its obvious i meant that the link that you suggest the codes in that link didn't work
              sorry because of bad explaining

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lgeyer
                wrote on 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 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 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 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 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 last edited by VRonin
                          #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 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 last edited by
                              #15

                              Use showNormal() instead.

                              1 Reply Last reply
                              0
                              • Z Offline
                                Z Offline
                                zidom
                                wrote on 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 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

                                  • Login

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