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 get minimum size Mainframe?
QtWS25 Last Chance

How to get minimum size Mainframe?

Scheduled Pinned Locked Moved Solved General and Desktop
qwidget
8 Posts 5 Posters 540 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.
  • S Offline
    S Offline
    SiGa
    wrote on 16 May 2024, 08:14 last edited by
    #1

    Hi Forum,
    I want a mainframe that can not get smaller than the collection of the minimum size widgets it contains.
    Is there a general setting or way how to achieve this, instead of writing my own resize event for the mainframe? Or ist that the only way?
    Could not find good info about this topic.
    Recommendations for other methods or ideas are welcome.

    J 1 Reply Last reply 16 May 2024, 08:40
    0
    • S SiGa
      16 May 2024, 08:14

      Hi Forum,
      I want a mainframe that can not get smaller than the collection of the minimum size widgets it contains.
      Is there a general setting or way how to achieve this, instead of writing my own resize event for the mainframe? Or ist that the only way?
      Could not find good info about this topic.
      Recommendations for other methods or ideas are welcome.

      J Offline
      J Offline
      JonB
      wrote on 16 May 2024, 08:40 last edited by JonB
      #2

      @SiGa
      I always fight with Qt layouts/policies too, even after all this time! Have you tried QSizePolicy::Maximum? You still have to calculate sizeHint() yourself dynamically to the bounding rectangle of the widget contents, I believe. Or there is setMaximumSize(). Whether this is any simpler than trapping resize event I don't know.

      S 1 Reply Last reply 16 May 2024, 09:21
      0
      • J JonB
        16 May 2024, 08:40

        @SiGa
        I always fight with Qt layouts/policies too, even after all this time! Have you tried QSizePolicy::Maximum? You still have to calculate sizeHint() yourself dynamically to the bounding rectangle of the widget contents, I believe. Or there is setMaximumSize(). Whether this is any simpler than trapping resize event I don't know.

        S Offline
        S Offline
        SiGa
        wrote on 16 May 2024, 09:21 last edited by
        #3

        @JonB
        Glad to hear that also experts struggle at some things , guess we are still human ;)

        I need to provide an example for better understanding.
        I have my GUI program which has a default size, that I assume the user will be happy with.
        Now the user changes the size of the mainframe(i.e. the topmost frame|widget) by dragging the corner with the mouse.
        He can drag it so small, that elements in the mainframe start overlapping and it turns unusable.
        I want to prevent dragging it to an unusable size.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mpergand
          wrote on 16 May 2024, 09:37 last edited by mpergand
          #4

          Can you provide more infos (code, screenshot)
          because that's not what I observe.

          If I do:

          MainWindow mw;
          mw.show();
          mw.resize(mw.minimumSize());
          

          The window cannot be resized smaller by the user or by code (seems logical).

          S 1 Reply Last reply 16 May 2024, 11:38
          0
          • M mpergand
            16 May 2024, 09:37

            Can you provide more infos (code, screenshot)
            because that's not what I observe.

            If I do:

            MainWindow mw;
            mw.show();
            mw.resize(mw.minimumSize());
            

            The window cannot be resized smaller by the user or by code (seems logical).

            S Offline
            S Offline
            SiGa
            wrote on 16 May 2024, 11:38 last edited by
            #5

            @mpergand
            If I set it like you did in your code, no GUI shows up because minSize is 0,0 at this point.

            I will test in on a MWE, and if it is still not working I will post the code.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SimonSchroeder
              wrote on 17 May 2024, 06:45 last edited by
              #6

              I'm not sure what you are doing. If the mainframe has a layout and all widget are inside nested layout, you cannot go below the minimum size of each individual widget and nothing will overlap. So, somehow you have used the layouts wrong. Without any code/.ui files it is really hard to diagnose the problem.

              1 Reply Last reply
              1
              • S Offline
                S Offline
                SiGa
                wrote on 23 Jul 2024, 09:34 last edited by SiGa
                #7

                I can not reproduce my problem anymore, and it behaves as all of you described.
                Thanks for the feedback.
                I will just mark JonB's answer as the correct one, since there is no correct answer.

                P 1 Reply Last reply 23 Jul 2024, 12:04
                1
                • S SiGa has marked this topic as solved on 23 Jul 2024, 09:35
                • S SiGa
                  23 Jul 2024, 09:34

                  I can not reproduce my problem anymore, and it behaves as all of you described.
                  Thanks for the feedback.
                  I will just mark JonB's answer as the correct one, since there is no correct answer.

                  P Offline
                  P Offline
                  Pl45m4
                  wrote on 23 Jul 2024, 12:04 last edited by
                  #8

                  @SiGa

                  As @SimonSchroeder said above, if you were using layouts properly, there's almost no way that things overlap, when resizing the main widget. Only free floating widgets, which are not part of any layout might do.


                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                  ~E. W. Dijkstra

                  1 Reply Last reply
                  1

                  • Login

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