PDA

View Full Version : How to put a DockWidget or Widget over others??



dungsivn
23rd October 2007, 12:56
Hi all,

In Qt 4.3, I want to create a small application similar to Slick Edit and have some troubles:

1. Auto Hide feature: how to add a Widget is same as "project" tab or "classes" tab in the left of the Visual Slick application, It means that, when users move over the "Project", "Classes", "FTP" tabs, these widgets will expand slowly and increase its size. The trouble is that when these tabs are increasing its size, these must above the central widget, don't push the central widget to the right. I imitate the way of QRubberband class by using: setAttribute(Qt::WA_NoSystemBackground) method so that the left widget can put over others but it does not affect. How can I do?

2. What should I do to replace the normal symbol on the top-right corner by the auto-hide symbol?

Thanks!

wysota
23rd October 2007, 14:13
I think dock widgets are not the way to go here. If you want to obscure the central widget, you'll need to use a widget that is not in the main window layout and use QWidget::setGeometry() or similar to control the position and size of the widget yourself using a timer to create animating effect.

dungsivn
24th October 2007, 02:47
Thanks, and what does function allow that widget over others?

wysota
24th October 2007, 08:00
QWidget::raise() should do the trick.

momesana
24th October 2007, 13:11
This might be of interest to you.
http://wiki.qtcentre.org/index.php?title=Fade_and_scroll_effects
These are the classes Qt uses internally for some simple animations. Even though easy to use they have a few drawbacks. They are appropriate for fast animations and optimized accordingly. Moving widgets using a QTimer/QTimeLine as Wysota suggested, ideally with a higher timer resolution (~20msec) will probably better suit your needs.

dungsivn
25th October 2007, 04:48
thanks all, and the last question: how to remove a widget out of a dock widget? I search in Qt assistant but can't found the way to do that. I only deleted the widget which was set into the dock widget, It right?

wysota
25th October 2007, 06:12
You can reparent (QObject::setParent()) the widget out of the dock widget and delete the dock widget.