PDA

View Full Version : scroll bars are not appearing



Cruz
20th January 2009, 16:46
I have a QFrame dropArea with QHBoxLayout inside a QScrollArea. Now I drop widgets on it with drag and drop.



ui.dropArea->layout()->addWidget(widget);
ui.dropArea->adjustSize();


I can see the adjustSize() working, the dropArea is growing with every widget I drop. But when it reaches the limit, the scroll bars don't appear like they should. The scroll bar policies are set to the default "as needed" by Designer. What do I need to tweak?

Cruz
20th January 2009, 17:28
I also tried setting a constraint on the layout size



layout->setSizeConstraint(QLayout::SetMaximumSize);


and updating the scroll area manually after the widget has been resized.



ui.dropArea->adjustSize();
ui.scrollArea->update();


Oh and even removing the style sheet. Nothing. No scroll bars.

Cruz
21st January 2009, 10:04
I don't know if I did something wrong, but it seems that adding a widget to a QScrollArea in Designer and then promoting it doesn't do the trick. I had to manually add a widget to the scroll area for the scroll bars to finally appear.



ui.scrollArea->setWidget(new DropArea(ui.scrollArea));


In Designer, first I created a QScrollArea. Then I took a QFrame and dragged it onto the QScrollArea until it was highlighted, so that it was clear that I'm adding the QFrame _to_ it. Then I promoted the QFrame to a DropArea (my custom class). That's the right way to do it isn't it?

After I spent hours of tinkering with the layout and sizes and the scrollbars just wouldn't appear, I created a minimal example and figured out that only an explicit scrollArea->setWidget(dropArea) will make it work right.

So then I went back to what I created with Designer and tried to make sure that the dropArea is set as widget of the scrollArea like this:



ui.scrollArea->setWidget(ui.dropArea);


The program crashes without any messages. I also checked if the ui.dropArea and the ui.scrollArea->widget() pointers are the same, they are not. So I think it must be so that Designer doesn't setWidget().

pavanbarot
10th September 2010, 10:04
unchecked this property in ui file
widget Resizable----- unchecked

then and then u got the scrollarea properly....
i hope u understand what i want to say u !!

ralph_pt
10th September 2010, 17:26
ui.scrollArea->setWidget(ui.dropArea);

did the compiler accpted this line?