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