QDockWidget::title (Need to change the font & size

2019-06-27 10:43发布

问题:

I have following style sheet set for QDockWidgets in my QT app. All the things mentioned in the style are working except for the font. Why is "font" is not detected & how could I change the font & size of QDockWidget title ?

QDockWidget::title
{
    font: 18pt "Roboto Lt";
    background: lightgray;
    padding-left: 10px; 
    padding-top: 4px;
}

回答1:

Font should be applied to the QDockWidget itself, not to the sub-control ::title

QDockWidget { font-family: "Roboto Lt"; font-size: 18pt; }


回答2:

Watch the font part in the Qt Reference: http://doc.qt.digia.com/qt/stylesheet-reference.html

Maybe you should try:

QDockWidget::title
{
   font-family: "Roboto Lt";
   font-size: 18pt;
   background: lightgray;
   padding-left: 10px; 
   padding-top: 4px;
}