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. What is the difference between layout default constraint and no constraint?
Forum Updated to NodeBB v4.3 + New Features

What is the difference between layout default constraint and no constraint?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 441 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.
  • D Offline
    D Offline
    Daniella
    wrote on last edited by Daniella
    #1

    I'm reading the documentation of QGridLayout but i still couldn't understand the difference between these two options of layout size constraint: SetDefaultConstraint and SetNoConstraint.

    Could someone help me understanding it a bit better?

    JoeCFDJ Chris KawaC 2 Replies Last reply
    1
    • D Daniella

      I'm reading the documentation of QGridLayout but i still couldn't understand the difference between these two options of layout size constraint: SetDefaultConstraint and SetNoConstraint.

      Could someone help me understanding it a bit better?

      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #3

      SetNoConstraint basically does nothing i.e. it does not change the widget's minimum or maximum sizes. If the widget had a min or max size it will keep it. If it didn't then it won't get any either.

      SetDefaultConstraint checks if the widget has explicitly set minimum size. If it does then it stays as was set. If it doesn't then widget gets minimum size set from the minimum size calculated by layout.

      In practice there's no visual difference. The widget won't get smaller than what the layout dictates whether it has minimum size set or not. If you manually set minimum size greater than that calculated by layout it will stay that way no matter which mode you choose - SetNoConstraint doesn't change it ever and SetDefaultConstraint won't change it because it was manually set.

      The difference is only when you don't explicitly set a minimum size. In that case SetDefaultConstraint sets it, while SetNoConstraint doesn't, so if you ask widget for its minimumSize() it will give you different results with those two modes.

      1 Reply Last reply
      2
      • D Daniella

        I'm reading the documentation of QGridLayout but i still couldn't understand the difference between these two options of layout size constraint: SetDefaultConstraint and SetNoConstraint.

        Could someone help me understanding it a bit better?

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #2

        @Daniella https://doc.qt.io/qt-5.15/qlayout.html#SizeConstraint-enum
        QLayout::SetDefaultConstraint 0 The main widget's minimum size is set to minimumSize(), unless the widget already has a minimum size.

        QLayout::SetNoConstraint 1 The widget is not constrained.

        1 Reply Last reply
        0
        • D Daniella

          I'm reading the documentation of QGridLayout but i still couldn't understand the difference between these two options of layout size constraint: SetDefaultConstraint and SetNoConstraint.

          Could someone help me understanding it a bit better?

          Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #3

          SetNoConstraint basically does nothing i.e. it does not change the widget's minimum or maximum sizes. If the widget had a min or max size it will keep it. If it didn't then it won't get any either.

          SetDefaultConstraint checks if the widget has explicitly set minimum size. If it does then it stays as was set. If it doesn't then widget gets minimum size set from the minimum size calculated by layout.

          In practice there's no visual difference. The widget won't get smaller than what the layout dictates whether it has minimum size set or not. If you manually set minimum size greater than that calculated by layout it will stay that way no matter which mode you choose - SetNoConstraint doesn't change it ever and SetDefaultConstraint won't change it because it was manually set.

          The difference is only when you don't explicitly set a minimum size. In that case SetDefaultConstraint sets it, while SetNoConstraint doesn't, so if you ask widget for its minimumSize() it will give you different results with those two modes.

          1 Reply Last reply
          2
          • D Daniella has marked this topic as solved on

          • Login

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