[Qt-interest] QTableView font and style sheets

Ilya Agafonov agf.ilya at gmail.com
Tue Nov 8 14:04:21 CET 2011


Hello!

I need to change font of my QTableView, and I'm doing it like this:
/tableView->setFont(font);/

And it worked until I set stylesheet to application (without setting 
font to QTableView, it choosed by user):
/qApp->setStyleSheet(anyStyle);/

I start searching where my font is changed back to default, and found it 
in QStyleSheetStyle::setPalette (qstylesheetstyle.cpp)...
/if (!w->property("_q_styleSheetWidgetFont").isValid()) {
     saveWidgetFont(w, w->font());
}/
... and and QStyleSheetStyle::unsetPalette:
/QVariant oldFont = w->property("_q_styleSheetWidgetFont");
if (oldFont.isValid()) {
     w->setFont(qVariantValue<QFont>(oldFont));
}/

Than I try to change font like this...
/tableView->setProperty("_q_styleSheetWidgetFont", font);/
...and it works! But now I'm feeling bad and cannot sleep, what if 
somebody will change "_q_styleSheetWidgetFont" to "_qt5_ssWidgetFont" or 
thomething?

My question is: If I using stylesheets, how can I change font of 
QTableView without using internal properties? Or how can I add and 
change font to current stylesheet of concrete QTableView object?

I'm using Qt 4.6.1, Windows, VS2005.

Best regards,
Ilya.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20111108/3dca3a46/attachment.html 


More information about the Qt-interest-old mailing list