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. FlowLayout uses too much height
Forum Update on Monday, May 27th 2025

FlowLayout uses too much height

Scheduled Pinned Locked Moved Unsolved General and Desktop
flowmingw32desktop
1 Posts 1 Posters 643 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.
  • J Offline
    J Offline
    JoeAB
    wrote on last edited by
    #1

    I am trying to use the FlowLayout sample to create a docked panel with 26 same-size buttons. The buttons are positioned OK and also flow properly when the width of the application is changed.

    However, the height of the panel remains constant and too large. I left these overridden functions as is, except for diagnostics.

    int FlowLayout::heightForWidth(int width) const
    {
    int height = doLayout(QRect(0, 0, width, 0), true);
    qDebug() << "heightForWidth(" << width << ") ht=" << height;
    return height;
    }

    void FlowLayout::setGeometry(const QRect &rect)
    {
    QLayout::setGeometry(rect);
    int height = doLayout(rect, false);
    }

    heightForWidth is only called once, using the width of roughly one button plus margins. The height calculated is for 26 rows (818 pixels), instead or 2 or 3 rows (105 or 136 pixels).

    Is there an easy way to get the FlowLayout to use the calculated height?

    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