Important: Please read the Qt Code of Conduct -

How do I customizing QTreeView header by stylesheet

  • I am trying to style the header of a QTreeView but there is nothing in the style sheet examples page pertaining to the header.

    my code

        m_model = new QStandardItemModel(this);
        m_model->setHorizontalHeaderItem(0,new QStandardItem(QString("Key")));
        m_model->setHorizontalHeaderItem(1,new QStandardItem(QString("Value")));
        QFile styleSheet = "./style/vmapViewer.qss";;

    my style sheet

    QWidget {
        background-color: #2D3D46;
    QTreeView {
        alternate-background-color: #171E22;
    QTreeView::branch {
        color: #fff;
    QHeaderView {
        color: #fff;
        background-color: #000;

    but as you can see, the headers are still white, along with the text


  • OK....then does anyone know how to find all the style sheet options for a particular object?

  • Moderators

    Headers are implemented via QHeaderView class so you need to style that, not QTreeView. See here for an example and here for a list of supported sub-controls and pseudo states.

Log in to reply