Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    2
    2
    324
    Loading More Posts
    • 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_Firelight
      Thuan_Firelight last edited by Thuan_Firelight

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • First post
          Last post