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. How to hide MaximizeButton of QMainWindow?
Forum Updated to NodeBB v4.3 + New Features

How to hide MaximizeButton of QMainWindow?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 5 Posters 9.5k Views 2 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.
  • S Offline
    S Offline
    sonichy
    wrote on 8 Nov 2017, 15:31 last edited by
    #1

    This do not work:

    setWindowFlags(windowFlags() &~ Qt::WindowMaximizeButtonHint);

    https://github.com/sonichy

    R 1 Reply Last reply 8 Nov 2017, 15:42
    0
    • S sonichy
      8 Nov 2017, 15:31

      This do not work:

      setWindowFlags(windowFlags() &~ Qt::WindowMaximizeButtonHint);
      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 8 Nov 2017, 15:42 last edited by
      #2

      @sonichy

      setWindowFlags( Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint );
      

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      S 1 Reply Last reply 10 Nov 2017, 08:10
      3
      • R raven-worx
        8 Nov 2017, 15:42

        @sonichy

        setWindowFlags( Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint );
        
        S Offline
        S Offline
        sonichy
        wrote on 10 Nov 2017, 08:10 last edited by
        #3

        @raven-worx This can disable maximize button but not hide it !

        https://github.com/sonichy

        R 1 Reply Last reply 10 Nov 2017, 08:17
        0
        • S sonichy
          10 Nov 2017, 08:10

          @raven-worx This can disable maximize button but not hide it !

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 10 Nov 2017, 08:17 last edited by
          #4

          @sonichy
          i think there is no Qt-way to remove the minimize and maximize buttons.
          You may want to set the Qt::Tool flag instead the Qt::Window flag:

          setWindowFlags( Qt::Tool );
          

          But this also changes the appearance and behavior of the window a bit. But tool-windows do not have minimize and maximize buttons but do also not appear in the taskbar.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          S 1 Reply Last reply 11 Nov 2017, 14:42
          1
          • R raven-worx
            10 Nov 2017, 08:17

            @sonichy
            i think there is no Qt-way to remove the minimize and maximize buttons.
            You may want to set the Qt::Tool flag instead the Qt::Window flag:

            setWindowFlags( Qt::Tool );
            

            But this also changes the appearance and behavior of the window a bit. But tool-windows do not have minimize and maximize buttons but do also not appear in the taskbar.

            S Offline
            S Offline
            sonichy
            wrote on 11 Nov 2017, 14:42 last edited by
            #5

            @raven-worx setFixedSize is more simple than setWindowFlags, but also disable Maximize button no hide it.

            https://github.com/sonichy

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 11 Nov 2017, 15:08 last edited by
              #6

              Hi
              If Qt::Tool is not what you want, i think disable it is the only options.
              It will not be hidden unless a Tool type.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SaaGar
                wrote on 29 Aug 2020, 12:01 last edited by SaaGar
                #7
                 this helped me:   Form.setMaximumSize(QtCore.QSize(width, height))
                

                class Ui_Form(object):

                def setupUi(self, Form):
                    
                    Form.setObjectName("Form")
                    Form.resize(328, 212)
                    Form.setMaximumSize(QtCore.QSize(352, 189))
                
                1 Reply Last reply
                0
                • Y Offline
                  Y Offline
                  YTech
                  wrote on 27 Oct 2021, 13:31 last edited by
                  #8
                  This post is deleted!
                  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