Important: Please read the Qt Code of Conduct -

problem with the sort indicator in QHeaderView QT5

  • Sort display image does not match the sort order.

    QSqlRelationalTableModel *model = new QSqlRelationalTableModel();
                this, &MainWindow::on_sortChanged);


    void MainWindow::on_sortChanged(int index, Qt::SortOrder order)
        qDebug() << index << order 
              << ui->tableView->horizontalHeader()->sortIndicatorOrder();

    when i click to header, i see:
    but qDebug print:
    0 Qt::SortOrder(DescendingOrder) Qt::SortOrder(DescendingOrder)
    I tried Qt 5.7.0 and Qt 5.6.2
    It's a QT bug or I doing something wrong?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you running a Gnome desktop environment ?

  • @SGaist Thanks! No, it's KDE (Kubuntu 16.10 x64)

  • Lifetime Qt Champion

    Can you check with your distribution provided Qt ?

    Also, can you try with one of KDE's application like KMail or any other that uses a QTableView ?

  • @SGaist Kontact and Krusader apps has the same bug.

  • Build application on Windows 7. No bug.

  • Lifetime Qt Champion

    Then it looks rather like a KDE Theme issue. You should check with them.

  • I think it is a "feature" in Qt style code:

    alt text

    Some UI developers thinks, that "^" is ascending sort indicator, other thinks it is a descending sort indicator.
    Qt platfom-dependend styles (QWindowsVistaStyle, QMacStyle, QGtkStyle, etc..) will draw indicator using current OS & theme settings, platform-independend styles (QFusionStyle, QWindowsStyle) will draw it as hardcoded in Q***Style.cpp

Log in to reply