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. QTableWidget Sorting
Qt 6.11 is out! See what's new in the release blog

QTableWidget Sorting

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 700 Views
  • 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.
  • P Offline
    P Offline
    Phamy1289
    wrote on last edited by
    #1

    I have my QWidgetTable sort enabled, however, when I go to sort the column "priority", it counts the 10s as part of the 1s.

    if (it.key() == "priority")
    {
    double val = it.value().toDouble();
    QString string = QString(%1).arg(val);
    table->setItem(row, 3, new QtableWidgetItem(string);
    }

    926726db-2bc2-4393-87f6-3fc37ad282cf-image.png

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Because you set a QString, not an integer. Use setData() and set the integer instead a QString.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • P Offline
        P Offline
        Phamy1289
        wrote on last edited by
        #3

        That was it, thank you!

        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