[Qt-interest] How to make a dialogue box with scroll bars?

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Thu Mar 24 00:21:46 CET 2011


Hi Robert, 

> Sent: Thursday, 24 March 2011 04:37
> 
> I've been playing round for the last several hours trying to get a 
> dialogue box with lots of large buttons on it so that it has 
> scroll bars 
> so you can see all the buttons.
> 
> There are forty-five of these large buttons so the dialogue 
> will need to 
> scroll a a long way down for the user to select the 
> appropriate button 
> at times.
> 
> I have tried all sorts of thins like putting all the buttons in a 
> QScrollArea on Qt Designer, putting the buttons in a QFrame and then 
> following the Image Viewer Example, but rather than putting 
> the imagine 
> in a QScrollArea I put the frame in it. (This latter one just 
> makes all 
> the buttons disappear. I tried it like this in my config_dialogue 
> constructor (where config_dialogue is my dialogue!).
> 
> 	scrollArea = new QScrollArea;
> 	scrollArea->setBackgroundRole(QPalette::Dark);
> 	scrollArea->setWidget(ui->pictureFrame);
> 
> Where pictureFrame is a QFrame on which I place the [large] buttons.
> 
> I have seen other suggestions Googling around to do similar things to 
> the above bit of code, but this just doesn't work.
> 
> My gut feeling is that this should be a piece of cake in 
> Designer and I 
> shouldn't have to write code to do it, but I am stuck. Would be very 
> grateful for a pointer on how I can do this.
> 
> Many thanks. :~)

I created the attached by these steps in 4.6.0 designer: 

- Create the dialog
- Drag a scroll area onto the dialog
- Set the dialog layout to vertical
- Drag a frame onto the scroll area widget
- Set the scroll area layout to vertical (which actually sets it on the
internal scroll area widget). 
- Dragged several buttons onto the frame
- Changed their minimum height to 100
- Set the frame layout to vertical

Voila! 

Hope that helps, 

Tony
-------------- next part --------------
A non-text attachment was scrubbed...
Name: designer_scroll_area.png
Type: image/png
Size: 8418 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110324/67e43ecc/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scroll_area.ui
Type: application/octet-stream
Size: 4026 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110324/67e43ecc/attachment.obj 


More information about the Qt-interest-old mailing list