How does view's stylesheet interact with model's ::FontRole in Qt model/view environment?

StackOverflow https://stackoverflow.com/questions/22860999

  •  27-06-2023
  •  | 
  •  

Вопрос

What happens when font family and size supplied by stylesheet of QTreeView differ from the ones returned by the model assigned to it? So far it seems like model's data overrides stylesheet settings. How do I change font of a view with a custom model assigned to it then?

Or to be more precise: if I know I want to style the view with stylesheet - what do I return from model when ::FontRole is requested?

UPD: just in case I am doing something stupid, here is my stylesheet that I assign to qtreeview:

QTreeView::item:selected
{
    color: black;
    font-family:"Times New Roman", Times, serif;
}

QTreeView::item:has-children
{
    font-family: "Comic Sans MS", cursive, sans-serif;
    height: 25px;
    border-bottom: 1px solid;
    border-bottom-color: green ;
    border-top: 1px;
}
Это было полезно?

Решение

After some asking around and googling it turned out that styling text in QTreeView should be done on QTreeView instead of QTreeView::item

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top