PDA

View Full Version : QT Designer Scroll Area not working as expected.



red
19th July 2010, 15:49
Hello all!

I am an Autodesk maya 2011 user and I am trying to create a UI in QT with a Scroll Area in it.
However so far I have not been able to get it working. I searched a lot for this problem but so far I have not found anyone with a similar problem.
I also checked the help file on this problem but the scroll area topic in the help file only focuses on using scroll area’s within code.
As far as I know I can not use any form of scripting/code except for the script in the UI file itself since Autodesk Maya only reads the UI file. Other than that I am a complete novice using QT. :)

Problem:

When I create a Scroll Area in a mainWindow and place any layout or widget inside of it that is larger than the Scroll Area the Scroll area does not show any Scroll bars. Even if I set the verticalScrollBarPolicy to alwaysOn then it only shows a grayed out scrollbar.
In QT aswell as in maya (ofcourse)

I'm sure that I am forgetting something... Do I need to do anything extra in order to make the Scroll Area work.

Any help or suggestions would be most appreciated.

Thanks!!

Red

ChrisW67
19th July 2010, 22:45
What are the minimum sizes on the contained objects? If they are 0x0 then they will simply shrink to nothing with the shrinking QScrollArea/layout and never trigger the scroll bar requirement.

BTW: I have no idea what Autodesk Maya has to do with any of this.

red
20th July 2010, 13:03
I checked the minimum size and that was all ok, and also used crazy test values to make absolutely sure that the objects inside the scroll area would be big enough.
But i think i have it working now. By putting the scroll area within a grid layout.

Ahm the reason why I mentioned Autodesk Maya is because I saw a lot of examples of scroll layouts where the cpp(or one of the other files :D) files were used to create the scrolling effect. And as far as I know Maya can not use those files.

Thanks for your time and suggestions !

wysota
20th July 2010, 16:42
Show us your ui file.

red
20th July 2010, 20:26
Here is my ui file.
For some reason i can not get it to work within a single scroll area.
But if i put it into a grid layout then it does work.

http://www.redace.nl/Scripting/QT_GuiDesign/mainwindow.ui
(had to upload it to my own site because of 19.5kb upload limit.)

wysota
20th July 2010, 21:09
You didn't apply a layout on the scroll area's widget. It's enough to click on the empty area on the scroll area and apply a layout (i.e. a vertical one). Your frame also doesn't have a layout. You can't expect size adjustment features to work if you don't use layouts.

red
20th July 2010, 21:26
ah ok so thats it.Makes sense. :D

Thank you very much for the info !

robomat
30th July 2010, 17:00
Hi folks,
Trying to do the same here, also for a Maya 2011 PyQt4 application, and I'm running into the same problem.
The Dialog consists of a scroll layout and various group boxes all vertically aligned in the mainDialog window. The scroll layout itself also has some vertically aligned group boxes with a min height as child objects. When creating an instance of the UI in Maya scroll bars won't show up regardless of the size of the window. However, when testing the UI in designer (v4.6.2) everything is fine.

Here's the ui file (sorry, uploading doesn't seem to work):
http://klonko.de/files/test.ui

Thanks for any help
Robin

red
31st July 2010, 17:44
Hey robomat,

i have no idea what is wrong with your file.

when I load it into maya 2011 it works perfectly


5024

You could check your maya settings.
preferences- interface- remember size and position

to absolutely be sure that its not the maya settings. Make a backup of your mydocuments maya folder. and then delete it.

then maya will rebuild the folder with default settings. after that you can just put it back.

Btw here is the code in maya i used to load the ui



string $dialog = `loadUI -uiFile ("D:/test.ui")`;

showWindow $dialog;

robomat
2nd August 2010, 12:10
That's right, this is the same behaviour like the preview in QtDesigner, but this is just loading the UI file without any context. For my application I need to compile the UI file to .py. Anyway, getting the scrollbars is no problem anymore, thanks to the pyqt docs:
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qscrollarea.html

... If the widget exceeds the size of the frame, the view can provide scroll bars so that the entire area of the child widget can be viewed. The child widget must be specified with setWidget().

So I did that and scrollbars show up, but the contents of that scrollArea now behave like they're disabled. In this case I have a scrollLayout that holds a frameLayout containing some groupBoxes containing checkbox widgets, just like this


scrollArea
|
|_frameLayout
|
|_groupBox1
| |
| |_checkBox1
| |_checkBox2
|
|_groupBox1
|
|_checkBox3
|_checkBox4

When attaching the frameLayout to the scrollLayout via setWidget() the I cannot toggle the checkboxes anymore. If I skip setWidget() all works fine, but no scrollbars show up.

Any idea, what's going on here?

Many thanks
Robin

robomat
2nd August 2010, 14:07
Got it! The thing I did wrong was to attach a QFrame to the scrollArea instead a QWidget. When creating a QScrollArea with designer it automatically creates a QWidget child object called scrollAreaWidgetContents which needs to be used as the argument for setWidget().

Cheers
R