PDA

View Full Version : How to drag a qtabwidget into a new window



cranfss
27th April 2010, 20:27
I haven't had much success in figuring out how or whether it is possible to drag a tab widget into a new window. I am using qt 4.6 on ubuntu. An example application is firefox or gedit.

Any help would be appreciated.

cranfss
28th April 2010, 19:52
anyone used ktabwidget to drag a tab into its own window?

SixDegrees
28th April 2010, 21:34
anyone used ktabwidget to drag a tab into its own window?

No; QTabWidget doesn't support tear-off tabs. If you want something like that, you have to implement it yourself. Have a look at Qt's Drag-and-Drop functionality, for starters. You'd have to create a new window (probably a Dialog) containing a copy of your tab's widget when you sensed the drag signal, render your widget at reduced size onto a decoration-free version of the dialog, and turn on decorations when drag release is sensed if it occurs outside the main window, or destroy everything otherwise. You'll also have to remove the tab in question from your main window if the drop is successful.

Reversing all this to put the window contents back in place would be the next step, plus rendering a positional indicator on the target tab stack.

Tear-off tabs would be a nice addition to Qt, but you could roll your own.