Results 1 to 14 of 14

Thread: QTabBar with optional button to the right of every tab

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QTabBar with optional button to the right of every tab

    Hi, I want to have an extra button on a QTabBar, like the closeButton in Firefox. My current solution is subclassing from QTabWidget and doing the drawing myself. It works but I'm losing the boons of CSS-Styling . This way I need to write a new class every time I want to implement a different look. Is there a way to achieve the same effect without losing the Styleability of the widget or is it possible to access the defined stylesheet values without doing all the parsing logic so I can try to take them into consideration when painting the tabbar? ... like getter functions for the properties and also the properties for the subcontrols?

    Thanx in advance
    Last edited by momesana; 6th October 2007 at 21:46.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTabBar with optional button to the right of every tab

    I'm not 100% sure but I think some of those Qt 4 dedicated IDEs out there have such tabs. Of course, it has also been suggested to Trolltech: http://trolltech.com/developer/task-...ntry&id=137891
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTabBar with optional button to the right of every tab

    To be honest QTabBar/QTabWidget API sucks when it comes to modifying it. If you take a look at the sources, it depends heavily on P-IMPL and QStylePainter. In my opinion these classes need to be redesigned. It might be hard because of a need to maintain backward compatibility, but currently QTabBar is surely one of the hardest widgets to extend, so something should be done about it. The least they could do is to introduce the "icon" property (or taking the icon from the widget associated with the tab) and "iconClicked()" signal. That should be doable without introducing any virtual methods.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTabBar with optional button to the right of every tab

    Thanks for replying. I guess then I have to use my own class and sacrifice Stylability until the trolls come up with a better solution (I hope they do, even though it doesn't seem like they care too much from looking at the bug entry).

    Thanx.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTabBar with optional button to the right of every tab

    It could be because it would be hard to implement on MacOS for instance... MacOS tab bars don't have space for icons and it'd look silly if you just sticked an icon there.

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTabBar with optional button to the right of every tab

    Quote Originally Posted by wysota View Post
    It could be because it would be hard to implement on MacOS for instance... MacOS tab bars don't have space for icons and it'd look silly if you just sticked an icon there.
    I've never worked with MacOS so I can't tell but generally having such an optional icon is a good thing, at least when it really is optional. It really improves usability when there are many open tabs like in a browser.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTabBar with optional button to the right of every tab

    I know it's a good thing. I've been trying to implement that d**n thing on QTabBar for days... Each time I ended up concluding that currently one needs to implement almost everything from scratch.

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTabBar with optional button to the right of every tab

    Quote Originally Posted by wysota View Post
    Each time I ended up concluding that currently one needs to implement almost everything from scratch.
    Same result here...
    J-P Nurmi

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTabBar with optional button to the right of every tab

    Quote Originally Posted by jpn View Post
    Same result here...
    Maybe we should cooperate? It would only be half a scratch each

  10. #10
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTabBar with optional button to the right of every tab

    A joint venture between libQxt and wwidgets :-D and I'll be the consumer of the result :-D.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTabBar with optional button to the right of every tab

    Honestly I don't think we'd be able to do anything really useful and platform independent without Trolltech changing the API. The widget simply relies too much on p-impl and style code. Without decoupling those there is not much we can do - there is no API to retrieve the icon rect of each tab for instance.

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.