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. How to check if the QTableWidget has similar rows
Forum Updated to NodeBB v4.3 + New Features

How to check if the QTableWidget has similar rows

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 3.0k 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.
  • I Offline
    I Offline
    Indrajeet
    wrote on last edited by
    #1

    Hi All

    I have created a table using QTableWidget.Which has 10 columns.
    How to check wether any of rows has similar data.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      That would depend on your definition of "similar". If you mean "identical", then you would first sort the data in the widget, and then iterate over the rows, first comparing the cell in the column on which you sorted, and then (if they match) the other cells untill they either do not match, or you reach the end of your columns (and you found a pair of matching rows).

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fluca1978
        wrote on last edited by
        #3

        Uhm...sounds like you have to define/extends a model with the logic for similar matching in it.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          Indrajeet
          wrote on last edited by
          #4

          Hi Andre

          Here similar i mean to say is 2 or more rows with same data.
          But checking each cell by cell will affect performance right?

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fluca1978
            wrote on last edited by
            #5

            Of course performing a check of each row/cell against each other will affect performance. Maybe you can restrict the data to check against a unique set of columns. Hard to say without knowing which kind of data you are manipulating.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              If you use the TreeWidget approach, you have to access the data cell by cell.
              If you go the way with model/view you can do an optimized way in the model.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • I Offline
                I Offline
                Indrajeet
                wrote on last edited by
                #7

                Hi Gerolf

                Can you please show me with example of 3 rows & 3 columns.
                How to use model/view for finding rows with same data.

                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