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. Convert values in QListView
Forum Updated to NodeBB v4.3 + New Features

Convert values in QListView

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 1.7k 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.
  • D Offline
    D Offline
    derilshows
    wrote on last edited by derilshows
    #1

    Hi!

    My QListView after SQL query has that list:
    40
    40002F
    40231S
    40297S

    And I want to convert all values that begin at 40 to 40, without duplication, so it should be:
    40

    Can you help me?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      derilshows
      wrote on last edited by
      #2

      Can anybody help?

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

        Hi,

        Please practice some patience, allow 24 hours before bumping your own thread. This is a community driven forum and not everybody lives in the same timezone as you.

        As for your question, what do you mean by convert ? Do you want to only show 40 to the users or do you want to modify the database itself.

        If the former, then you can implement a simple QStyledItemDelegate subclass and re-implement the displayText method to only return the two first digits.

        Hope it helps.

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

        D 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Please practice some patience, allow 24 hours before bumping your own thread. This is a community driven forum and not everybody lives in the same timezone as you.

          As for your question, what do you mean by convert ? Do you want to only show 40 to the users or do you want to modify the database itself.

          If the former, then you can implement a simple QStyledItemDelegate subclass and re-implement the displayText method to only return the two first digits.

          Hope it helps.

          D Offline
          D Offline
          derilshows
          wrote on last edited by
          #4

          @SGaist with sql query i can change values in one column. But it's the third column. The second shows month. In the first column are numbers.

          The structure is:
          Number, Month, Code

          Example. Was:
          200 02 04-03
          30 02 04-04
          10 03 04-05

          Now:
          200 02 04
          30 02 04
          10 03 04

          But the result should be (Sum, month, code):
          230 02 04
          10 03 04

          How to make function like that:
          if in the second and third columns of QTableView, values are the same, then make sum numbers in first column and make one line with that sum, month and a unique number.

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

            Isn't that the same question as here ?

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

            D 1 Reply Last reply
            0
            • SGaistS SGaist

              Isn't that the same question as here ?

              D Offline
              D Offline
              derilshows
              wrote on last edited by
              #6

              @SGaist yes, it is.

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

                In that case this one should be closed since the other one explain the problem directly.

                Duplicate

                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

                • Login

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