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. [SOLVED] Fixed size QDialog with platform-specific widget sizes
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Fixed size QDialog with platform-specific widget sizes

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 6.2k 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.
  • M Offline
    M Offline
    mnbv
    wrote on last edited by
    #1

    I want to make a QDialog that starts at it's minimum size and can't be resized.

    Different platforms/desktop themes have different minimum sizes for widgets; different default font sizes, item borders, etc, so I can't just set an absolute fixed size in the designer.

    How do I do this? How do I create a fixed size QDialog that looks good in any desktop environment?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      IIRC, you can use setSizePolicy with QSizePolicy::Maximum for that.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mnbv
        wrote on last edited by
        #3

        [quote author="SGaist" date="1392627281"]IIRC, you can use setSizePolicy with QSizePolicy::Maximum for that.[/quote]

        Thanks. I'm not sure I understand. Setting the size policy to Maximum (on either the dialog or the central widget) doesn't seem to affect the initial size and does not prevent the user from resizing the window. Can you clarify?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I have perhaps misunderstood your problem. Do you want to have a QDialog of a fixed size e.g. 300x300 and have it's content resized within that ? Or have the dialog getting an initial size when all widgets in it are created and then have it locked at that size ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mnbv
            wrote on last edited by
            #5

            I want to have the dialog get an initial size when all widgets in it are created, then have it locked at that size.

            I'm looking for the same behavior as e.g. a QMessageDialog, which gets an initial size based on the contents of its label and buttons (which vary based on content and on system metrics) but is a fixed size after creation.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Ok, then what you can do is:

              @setFixedSize(sizeHint());@

              This should give you a fixed size dialog containing all your widget with a sensible size

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mnbv
                wrote on last edited by
                #7

                Perfect, that works great. Thanks!

                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