Results 1 to 12 of 12

Thread: Tab Design

  1. #1
    Join Date
    Apr 2010
    Posts
    37
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Tab Design

    I was wondering (if possible) how to make my tabs look like this attachment.
    It looks like the left side is rounded and right side is triangular - what the heck?
    Please, help.
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Tab Design

    simple subclass QTabBarand do the painting yourself!

  3. #3
    Join Date
    Apr 2010
    Posts
    37
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tab Design

    Thanks for that recommendation. Is there any examples or tutorials online for painting?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Tab Design

    Qt Assistant is always a good point to start: http://doc.trolltech.com/4.6/examples-painting.html.

  5. The following user says thank you to Lykurg for this useful post:

    FoleyX90 (3rd May 2010)

  6. #5
    Join Date
    Apr 2010
    Posts
    37
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tab Design

    Having trouble performing: TabNavigator->setTabBar(myTabBar);

  7. #6
    Join Date
    Apr 2010
    Posts
    37
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

  8. #7
    Join Date
    Nov 2009
    Location
    Sacramento, CA
    Posts
    24
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Tab Design

    You have to derive from QTabWidget and QTabBar to do what you are trying to do.

  9. #8
    Join Date
    Apr 2010
    Posts
    37
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tab Design

    It works if, in qtabwidget.h, i move settabbar from protected to public.

  10. #9
    Join Date
    Nov 2009
    Location
    Sacramento, CA
    Posts
    24
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Tab Design

    Yea, but then you are breaking your license agreement. So if you extend QTabWidget, then you can call setTabBar in the constructor. Problem solved.

  11. #10
    Join Date
    Apr 2010
    Posts
    37
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tab Design

    This is probably horribly wrong (seeing as it doesn't work) but this is what i've put:

    Qt Code:
    1. #ifndef MYTABWIDGET_H
    2. #define MYTABWIDGET_H
    3. #include <QTabWidget>
    4. #include <QTabBar>
    5.  
    6. class MyTabWidget : public QTabWidget
    7. {
    8. public:
    9. MyTabWidget(QTabBar *);
    10. };
    11.  
    12. #endif // MYTABWIDGET_H
    To copy to clipboard, switch view to plain text mode 

  12. #11
    Join Date
    Apr 2010
    Posts
    37
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tab Design

    The cpp file:
    Qt Code:
    1. #include "mytabwidget.h"
    2. #include <QTabWidget>
    3.  
    4. MyTabWidget::MyTabWidget(QTabBar *)
    5. {
    6. QTabWidget::setTabBar(QTabBar *);
    7. }
    To copy to clipboard, switch view to plain text mode 

  13. #12
    Join Date
    Nov 2009
    Location
    Sacramento, CA
    Posts
    24
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Tab Design

    That should work, but i would do it more along these lines

    Qt Code:
    1. MyTabWidget::MyTabWidget(QWidget *parent)
    2. : QTabWidget(parent)
    3. {
    4. setTabBar(new MyTabBar(this));
    5. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. How to design?
    By zgulser in forum Qt Programming
    Replies: 5
    Last Post: 28th August 2009, 13:47
  2. Design help please
    By munna in forum General Programming
    Replies: 1
    Last Post: 31st May 2009, 18:05
  3. C++/QT Design
    By xmeister in forum Newbie
    Replies: 6
    Last Post: 2nd April 2009, 02:39
  4. Replies: 3
    Last Post: 5th October 2008, 23:41
  5. Design help please
    By munna in forum General Programming
    Replies: 1
    Last Post: 12th October 2006, 22:50

Tags for this Thread

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.