I try to set new font size for header and content of a tree widget.
Problem here is: I can not set font size directly for the content because at the moment I set, the content does not appear yet. So I can just set StyleSheet, so when content appears, it follows the StyleSheet. This is my code:
int modifier = 2;
/* Set font size for headers */
QFont f = ui.treeWidget->headerItem()->font(0);
if (f.pointSize() == 10)
f.setPointSize(f.pointSize() - 1);
else
f.setPointSize(f.pointSize() - modifier);
ui.treeWidget->headerItem()->setFont(0, f);
ui.treeWidget->headerItem()->setFont(1, f);
ui.treeWidget->headerItem()->setFont(2, f);
/* Set font size for content */
ui.treeWidget->setStyleSheet("{font-size: " + QString::number(f.pointSize()) + "}");
This is the result, the header font size is changed but the content is not. Where was I wrong, or do you have any other solutions for that?