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. QSpacerItem (inside a QWidget) is not shrinking inside a QScrollArea
Forum Updated to NodeBB v4.3 + New Features

QSpacerItem (inside a QWidget) is not shrinking inside a QScrollArea

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.8k 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.
  • S Offline
    S Offline
    soma_yarram
    wrote on last edited by
    #1

    Hello,

    I have elements associated in the following sequence:
    My_QDockWidget::setWidget(My_QScrollArea);
    My_QScrollArea::setWidget(My_QWidget);
    My_QWidget::setLayout(My_QStackedLayout);
    My_QScrollArea::setWidgetResizable(true);

    I added couple of My_Child_QWidget's to the My_QStackedLayout, and each My_Child_QWidget has a vertical and a horizontal QSpacerItems.

    The problem is that QSpacerItems in the My_Child_QWidget's are not shrinking and so the scroll bars always appears (even if not necessary).

    How can I make the My_Child_QWidget's QSpacerItems shrinkable and make My_QScrollArea's scroll bars disappear?

    I tried all of the size policies but none worked. Any help will be much appreciated.

    Thanks in advance...

    raven-worxR 1 Reply Last reply
    0
    • S soma_yarram

      Hello,

      I have elements associated in the following sequence:
      My_QDockWidget::setWidget(My_QScrollArea);
      My_QScrollArea::setWidget(My_QWidget);
      My_QWidget::setLayout(My_QStackedLayout);
      My_QScrollArea::setWidgetResizable(true);

      I added couple of My_Child_QWidget's to the My_QStackedLayout, and each My_Child_QWidget has a vertical and a horizontal QSpacerItems.

      The problem is that QSpacerItems in the My_Child_QWidget's are not shrinking and so the scroll bars always appears (even if not necessary).

      How can I make the My_Child_QWidget's QSpacerItems shrinkable and make My_QScrollArea's scroll bars disappear?

      I tried all of the size policies but none worked. Any help will be much appreciated.

      Thanks in advance...

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @soma_yarram
      you can try this.

      But to give an exact answer to your problem you will need to show some more code.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rondog
        wrote on last edited by
        #3

        Have a look at the sizes for the spacer items. For example:

        // horizontal spacer example
        	button_hspacer = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Minimum);
        	button_hlayout->addItem(button_hspacer);
        
        // vertical spacer example
        	widget_vspacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
        	widget_layout->addItem(widget_vspacer,10,0,1,3);
        

        I have the sizes set to zero (0,0) but anything that is small will work. The spacers will grow as needed and I have noticed the the Qt designer tends to put the real size that the spacer occupies when you created the form which makes it use that much space regardless.

        If this is not the reason then have a closer look at all the child widgets. I recently ran into a problem like this and found some child widget was the culprit.

        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