Results 1 to 8 of 8

Thread: Tear-off Tabs

  1. #1
    Join Date
    Apr 2007
    Posts
    20
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Tear-off Tabs

    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

  2. #2
    Join Date
    Jan 2006
    Posts
    368
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tear-off Tabs

    The closest thing I remember is this:
    http://kde-apps.org/content/show.php...?content=44015

    but it does exactly the opposite

  3. #3
    Join Date
    Apr 2007
    Posts
    20
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Tear-off Tabs

    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?

  4. #4
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Tear-off Tabs

    I guess the kde3's kmdi code (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
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tear-off Tabs

    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

  6. #6
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Tear-off Tabs

    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.

  7. #7
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Tear-off Tabs

    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.
    Attached Files Attached Files

  8. #8
    Join Date
    Oct 2016
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Tear-off Tabs

    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! ^.^

Similar Threads

  1. Replies: 2
    Last Post: 23rd July 2012, 09:42
  2. QTabWidget with same tabs
    By Djony in forum Qt Programming
    Replies: 20
    Last Post: 24th December 2011, 13:20
  3. How to make "west" tabs horizontal?
    By plumbum in forum Qt Programming
    Replies: 2
    Last Post: 7th June 2007, 11:32
  4. Switching off all tabs in QTabWidget
    By Gopala Krishna in forum Qt Programming
    Replies: 7
    Last Post: 30th August 2006, 18:10
  5. Removing Tabs
    By NewGuy in forum Qt Programming
    Replies: 6
    Last Post: 22nd July 2006, 23:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.