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. Qt on raspberry handling minimize and maximize buttons
Forum Update on Monday, May 27th 2025

Qt on raspberry handling minimize and maximize buttons

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 746 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.
  • M Offline
    M Offline
    MarcoChiesi79
    wrote on 24 Feb 2021, 14:37 last edited by
    #1

    Dear all,
    I'm developing a Qt application for Raspberry Pi 4 which should run in a custom display (1024x600), so I want that user cannot resize, maximize, minimize (collapse) any window of this application. I want that all the windows have fixed dimension, the ones that I designed for them. All windows (except MainWindow) are application modal or modal window.
    In each .ui file I set fixed values for minimumSize and maximumSize (i.e. (1024,600),(1024,600)): this allowed me to disable maximize button in all the windows, except one of them, which has not anything particular in its design to justify such behaviour. This is the first problem.
    Second problem is that minimize/collapse is always enabled, so windows can go to the taskbar, and I do not want that user could do it. Setting "Fixed" to sizePolicy in .ui file does not help.
    Using setWindowFlags does not help anyway, I tried a lot of combo with it, and no result at all...it seems it is simply ignored.
    I also tried to override changeEvent like this

    void MainWindow::changeEvent(QEvent* event)
    {
           if (event->type() == QEvent::WindowStateChange)
           {
                 if(isMinimized()
                          return;
           }
    }
    

    But this does not work anyway (maybe I wrote this function in a wrong way) because window get collapsed when minimized button is pressed.
    Any help will be really appreciated

    J 1 Reply Last reply 24 Feb 2021, 14:39
    0
    • M MarcoChiesi79
      24 Feb 2021, 14:37

      Dear all,
      I'm developing a Qt application for Raspberry Pi 4 which should run in a custom display (1024x600), so I want that user cannot resize, maximize, minimize (collapse) any window of this application. I want that all the windows have fixed dimension, the ones that I designed for them. All windows (except MainWindow) are application modal or modal window.
      In each .ui file I set fixed values for minimumSize and maximumSize (i.e. (1024,600),(1024,600)): this allowed me to disable maximize button in all the windows, except one of them, which has not anything particular in its design to justify such behaviour. This is the first problem.
      Second problem is that minimize/collapse is always enabled, so windows can go to the taskbar, and I do not want that user could do it. Setting "Fixed" to sizePolicy in .ui file does not help.
      Using setWindowFlags does not help anyway, I tried a lot of combo with it, and no result at all...it seems it is simply ignored.
      I also tried to override changeEvent like this

      void MainWindow::changeEvent(QEvent* event)
      {
             if (event->type() == QEvent::WindowStateChange)
             {
                   if(isMinimized()
                            return;
             }
      }
      

      But this does not work anyway (maybe I wrote this function in a wrong way) because window get collapsed when minimized button is pressed.
      Any help will be really appreciated

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 24 Feb 2021, 14:39 last edited by
      #2

      @MarcoChiesi79 Check this to see how to disable those buttons: https://stackoverflow.com/questions/38483932/how-to-disable-maximize-button-in-qt

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

      M 1 Reply Last reply 24 Feb 2021, 15:27
      1
      • J jsulm
        24 Feb 2021, 14:39

        @MarcoChiesi79 Check this to see how to disable those buttons: https://stackoverflow.com/questions/38483932/how-to-disable-maximize-button-in-qt

        M Offline
        M Offline
        MarcoChiesi79
        wrote on 24 Feb 2021, 15:27 last edited by
        #3

        @jsulm Hi, thank you for your fast reply!
        I examinated the webpage you linked a week ago and I used the suggestion to set same values for maximiumSize and minimumSize: this trick helped me to disable maximize button in all windows (except one, I do not know why it does not work for that window), but mimimize button is still enabled and working.
        Unfortunately, setWindowFlags and setFixedSize do not work anyway, I guess this is a Raspeberry pi issue (maybe related to its window manager?)

        M 1 Reply Last reply 24 Feb 2021, 15:35
        0
        • M MarcoChiesi79
          24 Feb 2021, 15:27

          @jsulm Hi, thank you for your fast reply!
          I examinated the webpage you linked a week ago and I used the suggestion to set same values for maximiumSize and minimumSize: this trick helped me to disable maximize button in all windows (except one, I do not know why it does not work for that window), but mimimize button is still enabled and working.
          Unfortunately, setWindowFlags and setFixedSize do not work anyway, I guess this is a Raspeberry pi issue (maybe related to its window manager?)

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 24 Feb 2021, 15:35 last edited by
          #4

          @MarcoChiesi79
          Hi
          Is it running the Raspbian distro or a custom linux ?

          Did you try
          setWindowFlag(Qt::Drawer,true);

          Normally gives
          alt text

          M 1 Reply Last reply 24 Feb 2021, 16:08
          0
          • M mrjj
            24 Feb 2021, 15:35

            @MarcoChiesi79
            Hi
            Is it running the Raspbian distro or a custom linux ?

            Did you try
            setWindowFlag(Qt::Drawer,true);

            Normally gives
            alt text

            M Offline
            M Offline
            MarcoChiesi79
            wrote on 24 Feb 2021, 16:08 last edited by MarcoChiesi79
            #5

            @mrjj
            Hi, I'm using QTCreator under raspbian, this is how the window appears:
            toolbar.png

            Unfortunately, setWindowFlag(Qt::Drawer,true) does not give any effect (I wrote this under ui->setup(this);)

            M 1 Reply Last reply 24 Feb 2021, 16:53
            0
            • M MarcoChiesi79
              24 Feb 2021, 16:08

              @mrjj
              Hi, I'm using QTCreator under raspbian, this is how the window appears:
              toolbar.png

              Unfortunately, setWindowFlag(Qt::Drawer,true) does not give any effect (I wrote this under ui->setup(this);)

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 24 Feb 2021, 16:53 last edited by
              #6

              @MarcoChiesi79
              Ok so it might be a Windows Manager issue.
              You could try to run
              https://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html

              and see which flags works. (if any)

              M 1 Reply Last reply 25 Feb 2021, 11:20
              1
              • M mrjj
                24 Feb 2021, 16:53

                @MarcoChiesi79
                Ok so it might be a Windows Manager issue.
                You could try to run
                https://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html

                and see which flags works. (if any)

                M Offline
                M Offline
                MarcoChiesi79
                wrote on 25 Feb 2021, 11:20 last edited by
                #7

                @mrjj Actually, the only two flags that change the situation are:

                • Qt::X11BypassWindowManagerHint, but this give the bad problem that window is not managed at all (and window title is gone). I prefer to keep my problem rather that get this
                • Qt::FramelessWindowHint, the only drawback is that window title is gone and, obviously, cannot be added with Qt::WindowTitleHint. I do not like windows without title, because it help user understanding which window is he using, but, actually, it could be a good compromise.

                I will keep search another solution for a bit, but if I won't find any, I will consider the question solved using Qt::FramelessWindowHint
                Meanwhile...thank you!

                1 Reply Last reply
                1

                1/7

                24 Feb 2021, 14:37

                • Login

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