Nominate our 2022 Qt Champions!

QTableView header background color for cell ZERO

  • Hello All,

    I need help regarding QTableView header background color change. I have a QTableView with both vertical and horizontal headers in it. I'm able to change the background color of both header other than one cell. The one cell at intersection of two headers (you may call is cell zero of both vertical and horizontal headers).

    I've following code to change the header color -
    header->setStyleSheet ("QHeaderView { font: bold 12px; font-family: microsoft sans serif; color: #5d6d7e; text-align: top right;}");

    and in model -
    QVariant dataModel::headerData(int section, Qt::Orientation orientation, int role) const
    QVariant header;

     if (role == Qt::BackgroundColorRole)
    	 return Qt::white;


    Please suggest if there is any way to fix this issue.

  • from

    The corner widget can be customized using the following style sheet

    QTableView QTableCornerButton::section {
        background: red;
        border: 2px outset red;

Log in to reply