PDA

View Full Version : QScrollArea - how use it in QT Creator?



Tomasz
6th September 2010, 11:21
Hello!

How can I use QScrollArea in QT Creator? I'm putting it on my MainWindow and putting inside it some objects but scroll bars doesn't work when objects are bigger ten scroll area.

thanks in advance
best regards
Tomasz

nish
6th September 2010, 11:40
some code would be helpful. Or can you re-frame your question

Tomasz
6th September 2010, 11:46
I don't have any code yet. I've just took 'Scroll Area' from 'Containers', put it on my window, an then put some stuff (like buttons) inside Scroll Area. Should I set some property to make it work? Other containers like 'Tab Widget' don't need any code.

thanks in advance
best regards
Tomasz

nish
6th September 2010, 11:49
oh i did not realize you are using qt designer for it. The scrollarea can only have one one widget inside it. you want many widgets, so you should make a custom widget and put that inside the scrollarea. sorry i dont work with designer.

Tomasz
6th September 2010, 11:54
But even with one widget like Label or something else It doesn't work (widget inside is bigger then scroll area to see scrolling effect).

thanks in advance
best regards
Tomasz

nish
6th September 2010, 12:00
widget inside is bigger then scroll area to see scrolling effect
you mean to say that the widget is bigger than the scrollarea and still the scrollbar doesnt come up? or the vice-versa?

Tomasz
6th September 2010, 12:01
Yes, widget inside is bigger, and scrollbar doesn't come up.

tbscope
6th September 2010, 13:08
Use layouts

Tomasz
6th September 2010, 17:18
I't works! Thanks! One more question about QScrollArea - how can I change width of scrolling bar? How should style sheet look like?

thanks in advance
best regards
Tomasz

MTK358
6th September 2010, 17:38
And as a reminder, you should ALWAYS use layouts for EVERYTHING, because they align everything perfectly, even if the user has a different theme/font size.

Tomasz
6th September 2010, 22:08
Ok. But what about changing style of scroll bar? I want to change its width. How should my code look?

thanks in advance
best regards
Tomasz

nish
7th September 2010, 10:26
take a look at the documentation for QStyle and QStylesheets