Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. problem with the sort indicator in QHeaderView QT5

problem with the sort indicator in QHeaderView QT5

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    melman
    wrote on last edited by melman
    #1

    Sort display image does not match the sort order.
    code:

    QSqlRelationalTableModel *model = new QSqlRelationalTableModel();
    model->setTable("records");
    ui->tableView->setSortingEnabled(true);
    connect(ui->tableView->horizontalHeader(), 
                &QHeaderView::sortIndicatorChanged,
                this, &MainWindow::on_sortChanged);
    ui->tableView->setModel(model);
    model->select();
    

    slot:

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

    when i click to header, i see:
    screenshot
    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Are you running a Gnome desktop environment ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Are you running a Gnome desktop environment ?

        M Offline
        M Offline
        melman
        wrote on last edited by melman
        #3

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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 ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          0
          • SGaistS SGaist

            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 ?

            M Offline
            M Offline
            melman
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • M Offline
              M Offline
              melman
              wrote on last edited by
              #6

              Build application on Windows 7. No bug.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

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

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mtrch
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved