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 can I prevent a widget to become as small as the "small but still usable" size if there's enough space?
Forum Updated to NodeBB v4.3 + New Features

How can I prevent a widget to become as small as the "small but still usable" size if there's enough space?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 359 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.
  • l3u_L Offline
    l3u_L Offline
    l3u_
    wrote on last edited by
    #1

    Hi all,

    I have a QDialog with a QTabWidget and a lot of widgets inside. The number of widgets and thus the needed vertical space is different. This leads to one of them being displayed vertically small, in the "small but still usable" mode:

    Bildschirmfoto_20240809_122247.png

    When I draw the dialog a bit taller, the style changes back to the "normal" mode:

    Bildschirmfoto_20240809_122259.png

    There would be enough vertical space if the dialog was initialized a bit taller. I played around with QSizePolicys, but the result is always the same.

    (How) Can I tell the widget to claim enough vertical space, so that it's big enough to not display that "tradeoff" style?

    Thanks for all hints!

    JonBJ 1 Reply Last reply
    0
    • l3u_L l3u_

      Hi all,

      I have a QDialog with a QTabWidget and a lot of widgets inside. The number of widgets and thus the needed vertical space is different. This leads to one of them being displayed vertically small, in the "small but still usable" mode:

      Bildschirmfoto_20240809_122247.png

      When I draw the dialog a bit taller, the style changes back to the "normal" mode:

      Bildschirmfoto_20240809_122259.png

      There would be enough vertical space if the dialog was initialized a bit taller. I played around with QSizePolicys, but the result is always the same.

      (How) Can I tell the widget to claim enough vertical space, so that it's big enough to not display that "tradeoff" style?

      Thanks for all hints!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @l3u_ said in How can I prevent a widget to become as small as the "small but still usable" size if there's enough space?:

      There would be enough vertical space if the dialog was initialized a bit taller.

      (How) Can I tell the widget to claim enough vertical space,

      These are quite different approaches. Which one do you actually want?

      For individual widgets did you try QSizePolicy::Fixed? Docs say this is used for vertical on a QPushButton so it does not shrink (or grow) vertically.

      For whole dialog you would have to set its size if you want it to be bigger, I don't think it will resize to accommodate non-shrunk content. Though I could be wrong.

      If you just want a lazy but quick solution/workaround, if you are using a QGridLayout-type on your pages you could call void QGridLayout::setRowMinimumHeight(int row, int minSize). Though that's not the correct way to do things.

      I play with everything till I get what I want with Qt widgets and/or Designer, it's a dark art!

      1 Reply Last reply
      1
      • l3u_L Offline
        l3u_L Offline
        l3u_
        wrote on last edited by
        #3

        Yay, setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); on all widgets to be added to the QTabWidget does the trick :-) Thanks for the hint!

        1 Reply Last reply
        0
        • l3u_L l3u_ has marked this topic as solved on
        • l3u_L l3u_ has marked this topic as unsolved on
        • l3u_L Offline
          l3u_L Offline
          l3u_
          wrote on last edited by l3u_
          #4

          Actually, this does help … but it does not really fix it, depending on the font size used …

          On my notebook, I have a 14" screen and thus use a bigger font (we're all not 20 anymore, are we?! ;-)

          However, this is what I get there:
          1.png

          So, due to the bigger font, I still get that "smaller but still usable" top-bottom compression. When I resize the dialog, the widgets grow to the size they should have, but they won't grow larger:
          2.png

          So, we're back to the initial question … Despite QSizePolicy::Fixed set for the vertical size, the widget can shrink a bit smaller, causing this "small but still usable" compression for the combo and spin boxes – and clipping the label texts that contain line breaks.

          No matter what I do, I can't seem to prevent the clipping. Also doing setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed) on each and every widget within the box does not change anything – I can still clip the label text and still "compress" the combo and spin boxes.

          What I also tried is to play with size constraints. When I do setSizeConstraint(QLayout::SetMinimumSize) on the box's layout, then the following happens:
          3.png

          The compression and clipping is gone – but now, the whole box is clipped instead :-( Resizing the dialog makes it visible again, and it also does not grow larger than the actually needed vertical size. But somehow, the layout thinks it does not need this space … either, it lacks inside the box, or outside of it …

          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