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

Robert Wood robert.wood at apostrophe.co.uk
Wed Mar 23 18:36:51 CET 2011


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. :~)



More information about the Qt-interest-old mailing list