PDA

View Full Version : Tear-off Tabs



Max Yaffe
3rd August 2007, 17:44
Hi forum fauna,

I'm casting about for an idea on implementing tear-off tabs in Qt. Essentially I want a QTabWidget where the pages behave like a QDockWidget, e.g. they can be torn off and floated past the bounds of the application or they can be returned back into the QTabWidget.

Anyone ever done anything like that? Any better ideas about how to approach it without breaking or adding too much Qt code?

Thanks,
Max

elcuco
3rd August 2007, 18:11
The closest thing I remember is this:
http://kde-apps.org/content/show.php/ideality?content=44015

but it does exactly the opposite :)

Max Yaffe
7th August 2007, 17:06
I looked at this web site but haven't been able to make heads or tails out of what they're doing, why they're doing it, or how it applies to my question.

Any other ideas?

Gopala Krishna
7th August 2007, 19:38
I guess the kde3's kmdi code (http://api.kde.org/3.5-api/kdelibs-apidocs/kmdi/html/files.html) (esp dockcontainer) did something similar. It seems to be bit old(qt3) and complicated. But i guess you will get vague idea on how to implement tearoff. Not sure though ;)

marcel
7th August 2007, 19:56
Anyone ever done anything like that? Any better ideas about how to approach it without breaking or adding too much Qt code?

I have worked on something like this, but for a commercial application,at work. They were much like the palettes in Photoshop.
I cannot post the code for it, but we used a custom tab bar/tab widget for this.
The drag&drop support and also the animations for them were a nightmare.

I home to do this again soon, in a personal project.

Regards

rajesh
8th August 2007, 14:26
Yes, I have done this in my application.
First time I have done this using QTabWidget but I got some other problem.
Later I have implemented using QDockWidget.
I have created many QDockWidget and tabified them so look like tab widget. in this way you can detach any tab.

I will make a sample code for you but it take some time.

rajesh
8th August 2007, 14:42
compile and run the attached file.
The Qt API does not support this, but you should be able to implement
this behavior yourself by reparenting the widget in the tab and place
it at the location where the mouse was released. You may also wish to
reimplement mousePressEvent() and mouseMoveEvent() in order to decide
if the tab widget should be teared off.

inside function dragMe, I am checking the distance of draged mouse if it more than 15 pixel then tear off.
void TabWidget::dragMe(int &movement)
{
int index=currentIndex();
int distance=15;

if( movement==distance)
{
...
}

But I have used another method by using tabify QDockWidget in my application.

novanox
21st October 2016, 22:48
Sweet, so the trick is to call setparent(0) on the tab!

Thank you.

Now to figure out how to detect and apply the drop! ^.^