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. Setting minimum size on a widget triggers a resizing to content
Forum Updated to NodeBB v4.3 + New Features

Setting minimum size on a widget triggers a resizing to content

Scheduled Pinned Locked Moved Unsolved General and Desktop
qwidgetqlayoutsize the qdockw
1 Posts 1 Posters 762 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.
  • dporobicD Offline
    dporobicD Offline
    dporobic
    wrote on last edited by dporobic
    #1

    I'm trying to figure out why and how to prevent a QDockWidget from resizing to content when setting minimumSize.

    I have few QDockWidget with some other widgets inside and need to collapse them sometimes, basically macing them invisible. Setting visibility works but has the drawback that all shortcuts are disabled which is a problem. Now I'm setting fixed size to 0 when collapsing and resetting size, minimum and maximum size when uncollapsing. First I was trying to just reset the size and maximum size but then I've noticed that I cannot resize the widgets anymore. When I set the minimum size the resizing is possible again but the widget resizes to content and basically ignores the stored size which was before collapsing.

    void AnnotationDockWidget::setCollapsed(bool isCollapsed)
    {
    	if (isCollapsed) {
    		mSizeBeforeCollapse = size();
    		setFixedSize(0, 0);
    	} else { 
    		setFixedSize(mSizeBeforeCollapse);
    		setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
                    setMinimumSize(0, 0);   // Doing this resizes the widget to its content and the mSizeBeforeCollapse is ignored. 
                                            // Without this line everything has correct size but I cannot resize the widgets.
    	}
    }
    

    Any idea how to prevent the resize to content or restore resizing capability without setting the minimum size?

    https://github.com/ksnip/ksnip

    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