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. Widget cross-platform (minimum) size constraint problem.

Widget cross-platform (minimum) size constraint problem.

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

    Hi All,

    First of all, I have had a look at the documentation, I've tried various combinations of setting minimum sizes, different size policies, calling updateGeometry() and adjustSize(), I've searched the forum for "qwidget minimum size" and others, I've asked Google...and I'm still stuck.

    Background
    I have a widget deriving from QScrollArea. This widget is populated with a bunch of QGroupBox'es in a horizontal layout (the main layout for the widget). Each QGroupBox contains buttons and/or other standard Qt widgets and all of them have layouts assigned to them and their content.

    The problem
    On Windows, I manage to ensure that the widget is created with the minimum size required to display the content WITHOUT having to show any scroll bars by setting the minimumSize property (using QtCreator and designer) and setting both the horizontal and vertical size policies to "Fixed". This works just fine.

    However, compiling the same code on Ubuntu (12.04 LTS), the widget is displayed with the horizontal scroll bar showing at start-up. Now, I can obviously sort that out (for Ubuntu) by playing around with the minimum size settings, but that kind of defeats the point of "code once, deploy everywhere".

    The question
    Is there a way to ensure that what I see in designer is what I get? In case this is not clear: is there a way to ensure that the widget, when set on a parent widget or window, will look exactly like it does when viewed in designer?

    Thanks for your help!

    http://www.goblincoding.com

    1 Reply Last reply
    0
    • M Offline
      M Offline
      master of disaster
      wrote on last edited by
      #2

      Windows and Ubuntu might have different opinions of when a scroll bar should be shown.

      Try this code:
      @
      scrollarea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
      @

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goblincoding
        wrote on last edited by
        #3

        Thanks for the post, but that won't work since it doesn't resize the widget, it simply "crops" the viewable area of the widget without giving the user the option to view the excluded parts with the aid of the scrollbar.

        http://www.goblincoding.com

        1 Reply Last reply
        0
        • M Offline
          M Offline
          master of disaster
          wrote on last edited by
          #4

          Well, then resize it:

          @
          widget.resize(new_width, new_height);
          @

          The parameters are both integers.

          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