Home > Mobile >  QTableView header background color changes
QTableView header background color changes

Time:10-06

In a custom model headerData () function by judging role==Qt: : BackgroundRole modify header background color, but doesn't work, the code is as follows, among them in the same way to modify the foreground, the text color is feasible, how to make the background color to take effect, please?
QVariant headerData (int section, Qt: : "Orientation" Orientation, int role) const
{
If (role==Qt: : DisplayRole & amp; & Orientation==Qt: : Horizontal)
{
If (section & lt; HeaderData. The size ()
Return HeaderData. At (section);
The else
Return QVariant ();
}

If (role==Qt: : BackgroundRole)
Return QBrush (QColor (Qt: : green));

If (role==Qt: : ForegroundRole)
Return QBrush (QColor (Qt: : red));

Return QVariant ();
}

CodePudding user response:

Is there a written proxy or CSS stylesheet

CodePudding user response:

Didn't write the agent, also did not use style sheets

CodePudding user response:

Today also in use qtableview seems only to form the "content", inside background or border are not, use the style sheet or agent (to headerview setting agent)
  •  Tags:  
  • Qt
  • Related