Unsolved How to make the ScrollAreaWidgetContents to be adaptive
-
I want to make the size of the
scrollAreaWidgetContents
can be adaptive so that theQScrollArea
can choose whether to display the scroll bar based on the content inside ( e.g.QToolBox
, I don't want to display the scroll bar inQToolBox
but inQScrollArea
). -
Hi,
Can you describe more precisely what kind of widget you are currently building ?
In any case, are you looking for the widgetResizable property ?
-
Thanks @SGaist .
Now there is a limited window and I want to show a member list in there byQToolBox
. So I useQScrollArea
and put the 'QToolBox' in it. Now I want the scroll bar adaptived (value and vision ) when one item inQToolBox
was opened and the window can't display all the contens, not need me to set the size ofscrollAreaWidgetContents
bigger thanQScrollArea
in advance and the scrollBar's value is fixed.
thewidgetResizable()
is true , what should I do. -
Hi,
i used it like this.
According to the status of the chartView scrollArea is or not.
on header file.
QChartView * chartView;
QScrollArea * scroll;on cpp file
chartView = new QChartView();
scroll = new QScrollArea;
scroll->setWidget(chartView);
ui->frame->layout()->addWidget(scroll);
scroll->setStyleSheet("background-color:transparent;"); -
Thanks @A-A-SEZEN
I will try donig that on cpp later,.
Now I just do that on designer, cus I can promote the widget easily. -
I don't understand why you want to put your QToolBox in a QScrollArea. AFAIR, it already handles large content itself showing scroll bars as needed.
-
@SGaist
Cus I want the scroll bar is a total scroll bar, not the scroll bar of each widget inQToolbox
. I think it is a bit unattractive and out of line with user habits.
Sorry maybe my request is a bit harsh. If it can not achieve this effect, I can make it with buttons and widget in a scroll area, just a bit complicated.
Thank you~ -
Can you show an example of the visual you are trying to produce ?
-
Hi @SGaist
I make a simple picture to show what I want. Each widget in toolbox can show all contents without blank and scrollbar. And if the entire toolbox is out of display in mainwindows(has a scrollarea), it will show the scrollbar (outside the toolbox).
I have read the source code ofQToolBox
, there is aQScrollArea
instruct Page
. I think we can add an attribute about how to show the contents in each page to let designers choose it, and remind the designers make sure the minimum size of each widget in each page. when one tab is clicked, the toolbox will be resized.
I hope and suggest this attribute will be used in new Qt version, cus I think it is more appropriate.
Also thanks @mrjj in here.
Regards.
Mihan