Where (if possible) could I find documentation or reference to make different tabs different colors/styles?
Where (if possible) could I find documentation or reference to make different tabs different colors/styles?
Here you go: http://doc.qt.nokia.com/4.6/styleshe...et-and-qtabbar
Extra tip: each tab has a name, use that name in your stylesheet to style each tab differently.
Oh my goodness. Someone actually replied to me. (I've posted 8 times on qtforum.org - never once received a reply) THANK YOU!
I have also tried: QTabBar::tab#tabPersonal and QTabBar::#tabPersonal
I don't use stylesheets that much, but try this:
If your first tab has the name tabPersonal, do this:
QTabBar::tab#tabPersonal {
background: red;
}
The documentation says:
ID Selector QPushButton#okButton Matches all QPushButton instances whose object name is okButton.
So I guess it should work on QTabBar::tab too.
http://doc.qt.nokia.com/4.6/stylesheet-syntax.html
http://www.w3.org/TR/CSS2/selector.html#id-selectors
You could also extend QTabBar and override the paint event, then for each tab choose a different color to paint them with.
Yea, I tried that but it didn't work. Maybe I'm just a lost cause.
Can you try: QTabBar#tabPersonal::tab ?
And if that doesn't work, set a stylesheet for each tab separately.
Example: tabPersonal.setStyleSheet("...");
tabNotPersonal.setStyleSheet("...");
I have also tried QWidget::tab#tabPersonal, QWidget#tabPersonal::tab etc.
Qt Code:
{ QStyleOptionTab opt; for(int i = 0;i < count();i++) { initStyleOption(&opt,i); //Set some color on the opt //Set some text color } }To copy to clipboard, switch view to plain text mode
That is a short example that should work. Not sure cause thats from memory.
This link should also help you get started if you can't figure out the style sheet.
http://doc.qt.nokia.com/4.6/style-reference.html#tabs
Sorry, I tried but it seems I can't find the answer for the stylesheet approach.
Best next thing to do is as Steno says, subclass and reimplement the paintevent
Sorry, I may need my hand held through this. I've never really extended classes in Qt using Qt Creator - I wouldn't know how to add the extended class to my .ui file.
How would i incorporate my newly defined class into my QTabWidget?
Bookmarks