PDA

View Full Version : QTableWidgetItem with specify type



evergreen
20th June 2011, 09:54
Hello,

I would like to specify the type (int, double, string) of each Item of my QTableWidget
I really want to use QTableWidgetItem to do it and no spinbox or lineEdit for performance issues.

Is there a way?

Rachol
20th June 2011, 10:34
Setting user type in the constructor?

evergreen
20th June 2011, 10:39
QTableWidgetItem::QTableWidgetItem ( int type = Type )

I don't understand this "type".
How does it work if I want to get a int or a string?

Rachol
20th June 2011, 10:48
create some enum like this:


enum MyItemType { INT = 1, STRING = 2, DOUBLE = 3 };

Then use your types to set it to the item in the constructor. With int QTableWidgetItem::type () const you can get what type you have set

evergreen
20th June 2011, 10:55
The point of all this is to make the item editable with the good type (the user can't put "toto" for an int item)

I'm not sure I understand the thing you've just explained, but it doesn't seems to me that it will check what the user writte in the item no?