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. Half-resizable window
Qt 6.11 is out! See what's new in the release blog

Half-resizable window

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 4.7k 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.
  • E Offline
    E Offline
    evergreen
    wrote on last edited by
    #1

    Hello everyone,

    I'm working on a main window. I want the user to be allowed to resize it vertically, but not horizontally.
    The fisrt idea I got was to put :
    resize(630, 380);
    setFixedWidth (630);
    in the constructor but it automatically disable the resize buton of the title bar (between close and reduce)
    Is it possible to impose an horizontal size but let this auto-resize option available verticaly?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      ludde
      wrote on last edited by
      #2

      Need some more info to understand what you are trying to do...
      By 'resize' / 'auto-resize', do you really mean 'maximize'?
      Or which platform / window system are you on?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        How about you set the minimum and maximum sizes for the widget, where for the width the minimum equals the maximum but for the height you give different values?

        1 Reply Last reply
        0
        • E Offline
          E Offline
          evergreen
          wrote on last edited by
          #4

          ludde : Sorry, I really meant maximized. I'm on windows XP.

          Andre : I tried to give the same minimum and maximum to width only but it also disable the maximize button.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            But it makes perfect sense that that disables the maximize button. If you limit the size to a specific width, you can not resize it to fill the screen (what the maximize button does). It would be confusing to the user if you have a maximize button, that does not actually maximize the window.

            1 Reply Last reply
            0
            • E Offline
              E Offline
              evergreen
              wrote on last edited by
              #6

              I see what you mean but I've already seen lots of apps that allow you to miximize only one dimension.
              Maybe the maximize action could be redifined.
              Maybe I'm a dreamer, I just begin with Qt!

              1 Reply Last reply
              0
              • L Offline
                L Offline
                ludde
                wrote on last edited by
                #7

                Seems like someone dictates that a window with a maximum widht or height should have a disabled maximize button. Not sure if it's Qt or Windows, though. If it's Qt you might be able to get around it, if it's Windows, it might be more difficult (at least using Qt code - you might find something in the Windows APIs).

                The fact that doing
                @w.setWindowFlags(w.windowFlags() | Qt::WindowMaximizeButtonHint);@
                on a window does not bring the maximize button back to enabled probably means that it is Windows, not Qt, that dictates this.

                1 Reply Last reply
                0
                • E Offline
                  E Offline
                  evergreen
                  wrote on last edited by
                  #8

                  Bad news tho...

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    evergreen
                    wrote on last edited by
                    #9

                    I found a simple solution for the one who find the same problem :

                    resize(630, 380);
                    setFixedWidth(630);
                    setWindowFlags( (windowFlags() | Qt::CustomizeWindowHint));

                    The flags enable the Maximize button, and respect the limited width.

                    Thanks for helps

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      ludde
                      wrote on last edited by
                      #10

                      Right... the documentation actually says you have to use Qt::CustomizeWindowHint to make Qt::WindowMaximizeButtonHint have any effect, so that was not so unexpected. If I would just have read the manual I would have probably have seen that too... :)

                      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