Results 1 to 3 of 3

Thread: QTreeView font size not being set

  1. #1
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTreeView font size not being set

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeView font size not being set

    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.

  3. #3
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTreeView font size not being set

    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.

Similar Threads

  1. Application default font
    By larry104 in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2006, 02:24
  2. change font size and button size of QMessageBox
    By nass in forum Qt Programming
    Replies: 6
    Last Post: 13th September 2006, 20:16
  3. Replies: 1
    Last Post: 8th May 2006, 08:07
  4. Why QStyle dosen't changes the standard font?
    By Dark_Tower in forum Newbie
    Replies: 8
    Last Post: 31st March 2006, 03:49
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 23:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.