Qt World Summit: Submit your Presentation

How to check if the QTableWidget has similar rows

  • Hi All

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

  • 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).

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

  • 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?

  • 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.

  • 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.

  • 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.

Log in to reply