QGridLayout max column width



  • How do I set a maximum width for QGridLayout columns?
    I don't want to set strech proportions with setColumnStretch, just a fixed maximum width.



  • Looking at the docs the QGridLayout takes QLayoutItem objects to fill its cells, can you sub class QLayoutItem and override its maximumSize property and use your new class in the grid?

    -=ben


  • Moderators

    Do you want to distribute your program to others? Or are you the only one that is going to use it? I guess not.

    In the first case you should consider the fact that others might want to use other fonts, and even bigger fonts. If your column width is not big enough for the bigger font you won't see it all. The purpose of Qt's layout system is to adapt automatically in this case.

    That's the reason why QGridLayout only has setMinimumColumnWidth and no similar function for maximum width.

    What you can do is use a widget for which you use setminimumsizehint. That way your column will adapt to the necessary space required to show that widget.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.