Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

CSS + QTableView/QHeaderView: font-weight ignored?



  • Hi all,

    As the title says...
    When selecting a table row the default behaviour is to set the vertical and horizontal header(s) to bold.

    My attempt was to force the font to be "normal" weight, but that did not work, but other properties could be set without problems using css.

    Example:

    QHeaderView::section:checked {font: 19px; color:blue;}
    QHeaderView::section {font: 19px; color:green;}
    

    works as expected and sets the text color to blue when clicking a row, green if not.

    Trying with

    QHeaderView::section:checked {font: normal 19px; color:blue;}
    QHeaderView::section {font: 19px; color:green;}
    

    does the same...
    screenshot
    Any ideas what I did wrong?


  • Moderators

    @the_ said:

    Any ideas what I did wrong?

    probably nothing. Some stuff is simply overwritten by the QStyle implementation.
    i can't tell you for sure that this is the case here. Would have to step through QStyle methods to see what happens with the font during painting.



  • @raven-worx
    Hi,

    thanks for your reply and information.
    Will mark it as "solved", as it is only a minor but interesting styling "issue" :)