October 12, 2011

Adi Adi
Lab Rat
206 posts

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.

6 replies

October 12, 2011

Andre Andre
Area 51 Engineer
6031 posts

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

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

October 12, 2011

fluca1978 fluca1978
Ant Farmer
524 posts

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

October 12, 2011

Adi Adi
Lab Rat
206 posts

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?

October 12, 2011

fluca1978 fluca1978
Ant Farmer
524 posts

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.

October 12, 2011

Gerolf Gerolf
Area 51 Engineer
3210 posts

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.

 Signature 

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

October 13, 2011

Adi Adi
Lab Rat
206 posts

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.

 
  ‹‹ reading a binary file      Inheritance of plugins with QPluginLoader not working? ››

You must log in to post a reply. Not a member yet? Register here!