Resize QScrollArea to fit content
-
Hello!
I got a QWidget inside a QScrollArea (see below)
@void Ui_Manager::setupUi(QWidget *manager)
{
QScrollArea *scrollArea = new QScrollArea();
scrollArea->setWidget(manager);
scrollArea->setWidgetResizable(true);
}@During Runtime i add several other Widgets to the Manager and move them into free space available inside the Manager-Widget:
@void addWidgets(QWidget *ptr, QPoint pos)
{
ptr->setParent(this);
ptr->move(pos);
ptr->show();
}@So it may happen, that the added Widgets were moved outside of the visible region of the Manager when there is not enough space available - thats the point where i hoped for the ScrollArea to take control and give me some nice ScrollBars to access the "hidden" Widgets. But it won't show me any ScrollBars and i don't have any idea why or how to change this.
This problem bothers me for a while now and i hope for someone here to give me a little hint :)Thanks!
-
Addition:
Just tried to add a Layout to the Manager and added the widgets to the Layout which made the Scrollbar work like a charm. But i can't use a Layout bcs I'm using drag&drop to move the added Widgets and using a Layout would overwrite positions of the widgets when the Manager-Window is resized.
This makes me even more confused :/Someone help me fix this please!