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. QSplitter not respecting the maximum size of the widget in Qt 5.12.3?
Forum Update on Monday, May 27th 2025

QSplitter not respecting the maximum size of the widget in Qt 5.12.3?

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

    Hi all,

    I am trying to troubleshoot an issue with vertical splitter. The splitter contains 2 widgets, a tree view and a custom widget and below is a simplified version of what the code roughly look like.

            mInspectorSplitter = new QSplitter(Qt::Vertical);
            mInspectorSplitter->addWidget(new QTreeView);
            mInspectorSplitter->addWidget(new CustomWidget);
            mInspectorSplitter->setStretchFactor(0, 1);
            mInspectorSplitter->setStretchFactor(1, 0);
    

    The custom widget has variable maximum size and can change based on user selection in the tree view. Depending on the selection, the custom widget can contain a widget that can expand or a fixed sized widget. When the expandable widget is displayed, the maximum height is 16777215, and when the fixed sized widget is display, the maximum height is 50.

    The problem I am encountering is when the maximum size of the custom widget is modified, the splitter does not automatically adjust for that. Stepping through the code, I can see QSplitterPrivate::doResize() is called whenever the maximum size of custom widget is changed. The size is then determined by this line:

            a[j].sizeHint = qMax(s->getWidgetSize(orient), a[j].minimumSize);
    

    Here getWidgetSize() would return the value of sizer (seems to be based on where the splitter was moved last) which in my case is greater than the maximumSize() of my custom widget. This caused some undesired behavior that would render an area of nothing and when attempting to move the splitter, it would snap to the maximumSize() of my custom widget correctly.

    Is this a bug or am I missing something?

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

      Hi,

      That looks strange indeed. Can you reproduce that with a minimal compilable example ?
      Did you also check with the latest Qt 5.13 to see if it's still the case ?

      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

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved