View Full Version : Tab Title Color
Hello All,
9050
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..
ChrisW67
22nd May 2013, 05:43
What error?
Hello ChrisW67, thanks for your reply.
My code as bellow:
// Test code:
QTabWidget *tb = ui->tabWidget;
tb->tabBar()->setTabTextColor(0, Qt::blue);
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..
ChrisW67
22nd May 2013, 08:58
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.
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?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.