Results 1 to 5 of 5

Thread: Tab Title Color

  1. #1
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Tab Title Color

    Hello All,

    Tab.zip

    I would like to use the Ui component to set the title color instead of using coding to do it. I have attach the sample code and my test code but my test code with error i have no idea how to clear the error . Can anyone tell me where is the problem and how to solve it?

    Thank you..

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Tab Title Color

    What error?

  3. The following user says thank you to ChrisW67 for this useful post:

    Qt52 (22nd May 2013)

  4. #3
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Tab Title Color

    Hello ChrisW67, thanks for your reply.

    My code as bellow:

    Qt Code:
    1. // Test code:
    2. QTabWidget *tb = ui->tabWidget;
    3. tb->tabBar()->setTabTextColor(0, Qt::blue);
    To copy to clipboard, switch view to plain text mode 

    The error is:
    1st Error: 'QTabBar* QTabWidget::tabBar() const' is protected
    2nd Error: within this context

    I'm not sure is it my code is correct if i want to change the tab text color in this way..

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Tab Title Color

    Now if only that error was present in the code you attached to your first post...

    The protected function QTabWidget::tabBar() is only available inside the code of QTabWidget of any subclass of it. Protected functions are standard C++ and not Qt specific.

    Some styling of tab bar tabs can be done through the Qt style sheet mechanism: Customizing QTabWidget and QTabBar. If that doesn't suit then you will need to subclass QTabWidget to add a public getter and setter pair for tab text colour.
    Last edited by ChrisW67; 22nd May 2013 at 08:02.

  6. The following user says thank you to ChrisW67 for this useful post:

    Qt52 (22nd May 2013)

  7. #5
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Tab Title Color

    emm...I'm not familiar with C++ too...but i know about embedded C.

    So, for my early question. Just make use of Ui component to do some of the configure like color-tab, color-text, font size, style, and so on.. is it possible to do that?

    I would like to try the "Customizing QTabWidget and QTabBar" code that you advice. Can you guide me how to add the code in my sample code?

    First should i need to create 2 new class in my project which is QTabWidget and QTabBar?
    Last edited by Qt52; 22nd May 2013 at 09:19.

  8. The following user says thank you to Qt52 for this useful post:


Similar Threads

  1. Replies: 4
    Last Post: 8th September 2011, 08:22
  2. Replies: 0
    Last Post: 13th October 2010, 13:57
  3. Replies: 3
    Last Post: 22nd January 2010, 16:46
  4. How to set color for QGroupBox Title
    By arunvv in forum Qt Programming
    Replies: 5
    Last Post: 4th December 2008, 17:50
  5. Title Bar Color
    By kaaty in forum Qt Programming
    Replies: 1
    Last Post: 8th December 2006, 16:32

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.