[SOLVED] scrollArea in scrollArea



  • Hi all!

    I m have class of the category with fixed height
    it's two labels, one scroll area and button "show\hide scroll area" plased with layout

    when i added to the scrollarea some widgets - the scrollarea blow up self height despite the height of category, respectively widgets show incorrect and gone out the border

    why the layout does not interfere?
    why setMaximumHeight on the scrollarea doesn't work?


  • Qt Champions 2016

    @MEPTPAH said:

    when i added to the scrollarea some widgets

    Should you not add it to the layout object and not the scrollarea ?

    Maybe you do.

    Its hard to give suggestions with no code/pictures.



  • @mrjj

    ...hope without code...

    void categoryWidget::_initScrollArea()
    {
    _scrollArea = new QScrollArea;
    _scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    _scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    _scrollAreaLayout = new QVBoxLayout(_scrollArea);
    _scrollAreaLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
    layout()->addWidget(_scrollArea);
    }

    after i am adding widgets (they can be like this), and now scroll area increas self height ignoring size of the parent where she is placed



  • solved:

    adding widget layer

    void categoryWidget::_initScrollArea()
    {
    _scrollArea = new QScrollArea;
    _scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    _scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    QWidget* _scrollAreaLayer = new QWidget;
    _scrollArea->setWidget(_scrollAreaLayer);
    _scrollAreaLayout = new QVBoxLayout(_scrollAreaLayer);
    _scrollAreaLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
    layout()->addWidget(_scrollArea);
    }

    Then scroll bar appears as need


  • Qt Champions 2016

    ah. the _scrollAreaLayer does respect the size limits then. Good to know.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.