[SOLVED] QTableWidget stylesheet not working in QTabWidget
-
Hello folks.
I don't no whether i'm missing something, or what I want to achive is impossible. I've created a little "example":http://huxi.uw.hu/hidden/Qt/styletest.tgz which demonstrates my problem. I have a QTableWidget in my MainWindow, and I have a QTableWidget in a QTabWidget, and the tab widget sits in a QDialog. No matter where I set the style sheet for the table widget in the dialog, it won't show up. The same stylesheet works fine for the table widget in the main window, and if I remove the tab widget, and just put my table in the dialog, the stylesheet is active again (try out for yourselfes).
Any help is appreciated.Thanks in advance!
-
i tried it on windows 7 and i have the same behaviour.
could be because of subclassing :
"Link to the docs":http://doc.qt.nokia.com/4.7-snapshot/stylesheet-syntax.htmlbq. Inheritance
In classic CSS, when font and color of an item is not explicitly set, it gets automatically inherited from the parent. When using Qt Style Sheets, a widget does not automatically inherit its font and color setting from its parent widget.
For example, consider a QPushButton inside a QGroupBox:@qApp->setStyleSheet("QGroupBox { color: red; } ");@
bq. The QPushButton does not have an explicit color set. Hence, instead of inheriting color of its parent QGroupBox, it has the system color. If we want to set the color on a QGroupBox and its children, we can write:
@ qApp->setStyleSheet("QGroupBox, QGroupBox * { color: red; }");@
bq. In contrast, setting a font and propagate using QWidget::setFont() and QWidget::setPalette() propagates to child widgets
-
Hi HuXiKa,
I'm back and I have your solution.
This is what I did (following the link to the docs I gave you) :
I deleted all stylesheets in both ui files and added one (long) line of code in the main.cpp to get that stylesheet for all widgets in your application (that's the goal of stylesheets, isn't it?)@
a.setStyleSheet("QHeaderView::section, QHeaderView::section * {background-color: qlineargradient
(x1:0, y1:0, x2:0, y2:1, stop:0 #616161, stop: 0.5 #505050, stop: 0.6 #434343, stop:1 #656565);
color: white; padding-left: 4px; border: 1px solid #6c6c6c;}");@of course you can do the same with the QTableWidget.
Cheers,
Eddy