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. Overriding paintEvent broke window minimizing from taskbar
Forum Updated to NodeBB v4.3 + New Features

Overriding paintEvent broke window minimizing from taskbar

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 5 Posters 1.0k 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
    loginmen
    wrote on last edited by
    #1

    A round clock example can be used as an example of code. The problem is this, if you override paintEvent then you lose the ability to minimize the window from the start menu (taskbar, not tray) by clicking of progamm icon. When you click on the program icon, nothing happens. At the same time, the folding itself through showMinimized works. And unfolding also works. How to fix? Windows 10, qt 6.1.2

    jsulmJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I doubt that paintEvent() has something to do with it. Please provide some code - a minimal compilable example would be the best - creating a simply QWidget with an overwritten paintEvent shouldn't be that hard.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • L loginmen

        A round clock example can be used as an example of code. The problem is this, if you override paintEvent then you lose the ability to minimize the window from the start menu (taskbar, not tray) by clicking of progamm icon. When you click on the program icon, nothing happens. At the same time, the folding itself through showMinimized works. And unfolding also works. How to fix? Windows 10, qt 6.1.2

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @loginmen Has nothing to do with paintEvent.
        Remove "Qt::FramelessWindowHint | Qt::WindowSystemMenuHint" and you will see that it works.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        L 1 Reply Last reply
        1
        • jsulmJ jsulm

          @loginmen Has nothing to do with paintEvent.
          Remove "Qt::FramelessWindowHint | Qt::WindowSystemMenuHint" and you will see that it works.

          L Offline
          L Offline
          loginmen
          wrote on last edited by loginmen
          #4

          @jsulm

          QWidget mainWindow {};
              mainWindow.setWindowFlag(Qt::FramelessWindowHint);
          

          Minimize fine, if do that

          Window::Window(QWidget *parent)
          : QWidget(parent, Qt::FramelessWindowHint) {
          //...
          }
          

          not working, but

          Window::Window(QWidget *parent)
          : QWidget(parent) {
          setWindowFlag(Qt::FramelessWindowHint);
          //...
          }
          

          work fine too, why?

          jsulmJ 1 Reply Last reply
          0
          • L loginmen

            @jsulm

            QWidget mainWindow {};
                mainWindow.setWindowFlag(Qt::FramelessWindowHint);
            

            Minimize fine, if do that

            Window::Window(QWidget *parent)
            : QWidget(parent, Qt::FramelessWindowHint) {
            //...
            }
            

            not working, but

            Window::Window(QWidget *parent)
            : QWidget(parent) {
            setWindowFlag(Qt::FramelessWindowHint);
            //...
            }
            

            work fine too, why?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @loginmen https://doc.qt.io/qt-5/qt.html#WidgetAttribute-enum
            "Qt::WA_TranslucentBackground 120 Indicates that the widget should have a translucent background, i.e., any non-opaque regions of the widgets will be translucent because the widget will have an alpha channel. Setting this flag causes WA_NoSystemBackground to be set. On Windows the widget also needs the Qt::FramelessWindowHint window flag to be set. This flag is set or cleared by the widget's author."

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            L 1 Reply Last reply
            1
            • jsulmJ jsulm

              @loginmen https://doc.qt.io/qt-5/qt.html#WidgetAttribute-enum
              "Qt::WA_TranslucentBackground 120 Indicates that the widget should have a translucent background, i.e., any non-opaque regions of the widgets will be translucent because the widget will have an alpha channel. Setting this flag causes WA_NoSystemBackground to be set. On Windows the widget also needs the Qt::FramelessWindowHint window flag to be set. This flag is set or cleared by the widget's author."

              L Offline
              L Offline
              loginmen
              wrote on last edited by
              #6

              @jsulm some error in message Qt::FramelessWindowHint instead of Qt::WA_TranslucentBackground

              jsulmJ 1 Reply Last reply
              0
              • L loginmen

                @jsulm some error in message Qt::FramelessWindowHint instead of Qt::WA_TranslucentBackground

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @loginmen What error?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                L 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @loginmen What error?

                  L Offline
                  L Offline
                  loginmen
                  wrote on last edited by loginmen
                  #8

                  @jsulm in the message wrote the wrong flag

                  jsulmJ 1 Reply Last reply
                  0
                  • L loginmen

                    @jsulm in the message wrote the wrong flag

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @loginmen Sorry, I don't understand what you mean. Please rephrase. Show code and exact error message.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    L 1 Reply Last reply
                    1
                    • jsulmJ jsulm

                      @loginmen Sorry, I don't understand what you mean. Please rephrase. Show code and exact error message.

                      L Offline
                      L Offline
                      loginmen
                      wrote on last edited by
                      #10

                      @jsulm correct message:

                      QWidget mainWindow {};
                          mainWindow.setWindowFlag(Qt::FramelessWindowHint);
                      

                      Minimize fine, if do that

                      Window::Window(QWidget *parent)
                      : QWidget(parent, Qt::FramelessWindowHint) {
                      //...
                      }
                      

                      not working, but

                      Window::Window(QWidget *parent)
                      : QWidget(parent) {
                      setWindowFlag(Qt::FramelessWindowHint);
                      //...
                      }
                      

                      work fine too, why?

                      J.HilkJ 1 Reply Last reply
                      0
                      • L loginmen

                        @jsulm correct message:

                        QWidget mainWindow {};
                            mainWindow.setWindowFlag(Qt::FramelessWindowHint);
                        

                        Minimize fine, if do that

                        Window::Window(QWidget *parent)
                        : QWidget(parent, Qt::FramelessWindowHint) {
                        //...
                        }
                        

                        not working, but

                        Window::Window(QWidget *parent)
                        : QWidget(parent) {
                        setWindowFlag(Qt::FramelessWindowHint);
                        //...
                        }
                        

                        work fine too, why?

                        J.HilkJ Offline
                        J.HilkJ Offline
                        J.Hilk
                        Moderators
                        wrote on last edited by
                        #11

                        @loginmen

                         Window::Window(QWidget *parent)
                         : QWidget(parent, Qt::WindowFlags() | Qt::FramelessWindowHint) {
                        //...
                        }
                        

                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                        Q: What's that?
                        A: It's blue light.
                        Q: What does it do?
                        A: It turns blue.

                        L 1 Reply Last reply
                        1
                        • J.HilkJ J.Hilk

                          @loginmen

                           Window::Window(QWidget *parent)
                           : QWidget(parent, Qt::WindowFlags() | Qt::FramelessWindowHint) {
                          //...
                          }
                          
                          L Offline
                          L Offline
                          loginmen
                          wrote on last edited by
                          #12

                          @J-Hilk still not working

                          JonBJ 1 Reply Last reply
                          0
                          • L loginmen

                            @J-Hilk still not working

                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by
                            #13

                            @loginmen
                            One thing just to verify: parent is being passed in as nullptr to your constructor, right?

                            L 1 Reply Last reply
                            0
                            • JonBJ JonB

                              @loginmen
                              One thing just to verify: parent is being passed in as nullptr to your constructor, right?

                              L Offline
                              L Offline
                              loginmen
                              wrote on last edited by
                              #14

                              @JonB That's right, he is the main widget (window), all his other children

                              JonBJ 1 Reply Last reply
                              0
                              • L loginmen

                                @JonB That's right, he is the main widget (window), all his other children

                                JonBJ Offline
                                JonBJ Offline
                                JonB
                                wrote on last edited by
                                #15

                                @loginmen
                                OK. if you say one works and one does not: on the first line in the constructor-argument one or the line after the setWindowFlag() one try printing out what's in windowFlags() and compare for any differences?

                                L 1 Reply Last reply
                                0
                                • JonBJ JonB

                                  @loginmen
                                  OK. if you say one works and one does not: on the first line in the constructor-argument one or the line after the setWindowFlag() one try printing out what's in windowFlags() and compare for any differences?

                                  L Offline
                                  L Offline
                                  loginmen
                                  wrote on last edited by
                                  #16

                                  @JonB in constructor i have flags:

                                  00000801
                                  

                                  and in use function:

                                  8800F801
                                  

                                  flags decode:

                                  80000000 WindowFullscreenButtonHint
                                  08000000 WindowCloseButtonHint
                                  
                                  00000001 Window
                                  00000800 FramelessWindowHint
                                  
                                  0000F000:
                                  00001000 WindowTitleHint
                                  00002000 WindowSystemMenuHint
                                  00004000 WindowMinimizeButtonHint
                                  00008000 WindowMaximizeButtonHint
                                  

                                  If i use

                                  Window::Window(QWidget *parent)
                                  : QWidget(parent, Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint) {
                                  //...
                                  }
                                  

                                  Minimize work fine and button not showing

                                  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