qscrollarea in .ui ?
-
HiH I have a problem with a qscrollarea that i have putted in the .ui and that doesn t work.
My scrollareawidgetcontents has a vertical layout as the widget that it is it and i add qlabel in this widget and then call resize() to increase the heigth.my qscrollarea has the properties widgetresizable and adjusttocontents.
The qscrollarea doesnt work.has anyone a good idea? -
-
Hi vronin and thanks but it is not exactly the same problem: i have a list of qlabel with text that i display in my widget and i want to scroll on it.if i put a addwidget on the layout when there are a lot of qlabel they are too small and the qscrollarea doesnt work.if i dont put addwidget i have the list of label but the qscrollarea doesnt work too and i dont see the end of the list.
-
@stephane78
Hi
Did you set Minimum size on the labels? did they become smaller when you added more?
Also, why a "list" of Qlabels inside scrollarea ? you can get a much better working version
with a List View / Widget. (if i may ask) -
@mrjj said in qscrollarea in .ui ?:
Also, why a "list" of Qlabels inside scrollarea ? you can get a much better working version with a List View / Widget. (if i may ask)
This is great advice
@stephane78 said in qscrollarea in .ui ?:
but it is not exactly the same problem
I still disagree:
#include <QApplication> #include <QScrollArea> #include <QLabel> #include <QVBoxLayout> #include <QPushButton> int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget mainWid; QVBoxLayout* mainLay=new QVBoxLayout(&mainWid); QScrollArea* imageScroll = new QScrollArea(&mainWid); QWidget* scrollWidget = new QWidget; QVBoxLayout* scrollLay=new QVBoxLayout(scrollWidget); QPushButton* addLabelButton = new QPushButton("Add Label",&mainWid); imageScroll->setWidget(scrollWidget); QObject::connect(addLabelButton,&QPushButton::clicked,scrollWidget,[scrollLay,scrollWidget]()->void{ scrollLay->addWidget(new QLabel("Some Label",scrollWidget)); scrollWidget->resize(scrollWidget->sizeHint()); }); mainLay->addWidget(addLabelButton); mainLay->addWidget(imageScroll); mainWid.show(); return a.exec(); }