Click here to Skip to main content
15,911,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to scroll my screen(Width/Height-320/240) top to bottom in stacked widgets.
For this I have done following steps in GUI
-> Taken scroll area from containers
-> click on widget
-> click on Layout in a Grid
->After trying to insert objects on layout

But I am unable insert more objects and screen also not scrolling.Can you please tell me the correct procedure.

What I have tried:

For this I have done following steps in GUI
-> Taken scroll area from containers
-> click on widget
-> click on Layout in a Grid
->After trying to insert objects on layout
Posted
Updated 26-Mar-18 19:47pm
Comments
Mel Flo 28-Aug-23 13:25pm    
Can you drag and drop the widgets you want into the layout? Normally, that is the way to do it.

1 solution

In my opinion, you should follow the steps below.

1:Taken one QScrollarea widget to main window.
2:Taken one QVBoxLayout into QScrollarea.
3:Taken some buttons into QVBoxLayout.

And in your cpp file, you should add some codes in constructors:

C++
//the vertical widget that I want to add to Area,change background color.
ui->verticalLayoutWidget->setBackgroundRole(QPalette::Dark);
//remove the widget in area;
ui->scrollArea->takeWidget();
//set this property
ui->scrollArea->setWidgetResizable(false);
//reset widget
ui->scrollArea->setWidget(ui->verticalLayoutWidget);


good luck.
 
Share this answer
 
Comments
Member 13740197 27-Mar-18 8:33am    
Sorry I am unable to find the QVBoxLayout in QT GUI,Can you please tell me how to take
Dean Feng 27-Mar-18 21:05pm    
It's name is Vertical Layout,belong to Layouts widget type. Class name of the widget is QVBoxLayout.
Member 13740197 28-Mar-18 5:33am    
I have taken vertical layout on Scroll area.But I had problem that when taking any object I am unable to resize width and height.Especially when taking label it is coming with maximum width & height equal to scroll area.But my requirement is to place a label beside another label.Can you please provide me the solution.
Dean Feng 28-Mar-18 21:29pm    
you can use QFrame instead,it's just a widget,you can use any to instead.
Member 13740197 31-Mar-18 10:02am    
Sorry Iam unable to understand this,Can you please provide me any video on how to scroll a screen.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900