PDA

View Full Version : QTreeView font size not being set



forrestfsu
11th October 2006, 16:42
Through Qt Designer 4.2.0, I added a QTreeView and set the font size to be smaller then default (8 pt). I also changed some labels to have the smaller font size. Whenever I compile my code, all the labels have the reduced font size, but the QTreeView does not. When I used to compile this code with Qt 4.1.4 it worked fine. I was wondering if I needed to do something different, or if there was a particular line of code I can try to add rather then using Qt to set its font size.

Thanks in advance.

wysota
12th October 2006, 00:21
You probably mean the items displayed in the view. It is possible that the view (or rather the delegate) renders items according to the font role of the model and ignores settings of the widget itself. So a solution would be to modify the font role for your model items. Another could be to set the font not from within Designer but using QApplication::setFont() instead.

forrestfsu
12th October 2006, 14:53
Thanks Wysota, I got it to work with something like this:

QFont fnt;
fnt.setPixelSize(9);
ui.treeView->setFont(fnt);

I was trying to condense that code into one line, but couldn't figure out how. Is it possible? It's not a big deal, just wanted to see if I could.