Scrolling bar problem in QScrollArea
Hello !
I have some widgets in horizontal layout, this layout was put in vertical layout and vertical layout was put in QScrollArea item.
Code:
gLayout->addWidget (searchAttrs);
vBLayout->setSpacing(6);
vBLayout->setMargin(0);
vBLayout
->setObjectName
(QString::fromUtf8("vBLayout"));
int num = 1;
hBLayout->setSpacing(6);
hBLayout->setMargin(0);
cbsAttrName->setEditable(true);
cbsAttrName
->setObjectName
(QString("cbsAttrName%1").
arg(num
));
cbsAttrName->setVisible (true);
this->cbsAttrNames.append (cbsAttrName);
hBLayout->addWidget (cbsAttrName);
this->cbsAttrRels.append (cbsAttrRel);
cbsAttrRel
->setObjectName
(QString("cbsAttrRel%1").
arg(num
));
cbsAttrRel->setVisible (true);
hBLayout->addWidget (cbsAttrRel);
sLEValue
->setObjectName
(QString("sLEValue%1").
arg(num
));
sLEValue->setVisible (true);
this->leVals.append (sLEValue);
hBLayout->addWidget (sLEValue);
sTBMore
->setObjectName
(QString::fromUtf8("sTBMore%1").
arg(num
));
sTBMore
->setText
(QString::fromUtf8("+"));
sTBMore->setVisible (true);
this->stbMore.append (sTBMore);
hBLayout->addWidget (sTBMore);
sTBFewer
->setObjectName
(QString::fromUtf8("sTBFewer%1").
arg(num
));
sTBFewer
->setText
(QString::fromUtf8("-"));
sTBFewer->setVisible (true);
this->stbFewer.append (sTBFewer);
hBLayout->addWidget (sTBFewer);
if (num==0)
vBLayout->addLayout (hBLayout);//, vBLayout->count()-1);
else
vBLayout->insertLayout (vBLayout->count()-1, hBLayout);
connect (sTBMore, SIGNAL(pressed()), this, SLOT (addAttr()) );
connect (sTBFewer, SIGNAL(pressed()), this, SLOT (delAttr ()) );
vBLayout->addItem (spacerItem);
If I press sTBMore toolbutton too many times then hBLayout height is decreasing, but vertical scroll bar in searchAttrs does not appear. Which way I have to make hBLayout fixed height and make scrolling in QScrollArea ?
Re: Scrolling bar problem in QScrollArea
Don't install a layout on the QScrollArea widget. Use QScrollArea::setWidget() to set a widget inside the scroll area.