View Full Version : QWidget positioning problem

24th June 2009, 16:59
I tried to create some widget (frame or panel, does not matter..) with children, but with some special behavior. This window will be automatically or manually dropped down or slide up under another widget.

Let's imagine we have one widget (with layout, or not) and three buttons on it, which are located one under another (like in vertical layout). You may consider them as "button group". This "button group" is located on the bottom! of our main widget.

Now we begin to resize that main window to a lower height. I need that "button group" to be moved with the bottom size of main window. And resizing should not be locked when a minimum size have been reached. The "button group" should move up and up, and finally should hide over the top border of our main window.

This looks like an "anchors" which we can set in some IDE's (C++ Builder, Delphi, ...)

You can find similar widget in the left part of windows XP's explorer. These are animated explorer task bars. They can be opened or closed. I found some examples of such widgets in for MFC, but i need the QT implementation.

Can anyone help me with my trouble?
Thanks ahead :)

24th June 2009, 17:08
Can you record some video what you mean, i don't understand? For recording you can use Camtasia Studio (in windows).

25th June 2009, 06:22
May be you are looking for QToolBox.
You can also do similar using QTreeWidget and delegates. You can search the forum for the same.

May be this link (http://doc.trolltech.com/qq/qq24-delegates.html) is also of help to you :)

25th June 2009, 07:16
ok brother what u want to achieve is considered by some as a problem thats why Qt has desigened its layout system such that it does not shrink more than its minimum size of contents...
may be u need to implement your custom layout.
take a look at this example http://doc.trolltech.com/4.5/layouts-flowlayout.html

25th June 2009, 08:35
Thanks for ideas, but a have to say a few words.

To SABROG: Open an explorer in windows XP. Take a look on the left panel. You will see drop down panels such as: System Tasks, Other Places, Details, and may be others. I need the same behaviour. It should be an animated drop down panel with widgets.
But i forgot to mention that it should be resizable. I have found one implementation but it uses grabWidget() to save the content of main form to a picture. It shows that picture, than hides form, and animates the picture instead of controls itself. It has some artifacts, because when we resize main form after collapsing it (the picture was stored with original width) and try to expand it, the picture scales and it does not looks good.
You can see it here: http://qt-apps.org/content/show.php/iisTaskPanel?content=79286
I believe it was not so good implementation :)

To aamer4yu: May be QTreeView can help me, but can it be smooth animated while closing/opening? QToolBox also can not be used, as it has no animation i need. It has a very different behaviour.

To MrDeath: It was a very good idea. I thought about custom layout, but i try to find more simple way for a while.:)
I don't want manually positioning of every widget in my form. I want to place all of them into a frame with layout, and than somehow fix them on it. And animate it.

29th June 2009, 10:29
Does anyone have an idea?

29th June 2009, 10:37
Did you check the link I gave in previous post ? (Designing Delegates (http://doc.trolltech.com/qq/qq24-delegates.html))
You can easily modify the header item to draw arrows or anything u like...play with that example.

30th June 2009, 07:56
ok, thanks! I'll try.