PDA

View Full Version : doubles and strings as items of a QTableWidget



fatecasino
29th January 2011, 18:24
Hi,
I want to create a simple QTableWidget consisted of strings and double numbers.
I want the user to edit these items and I want the program to access/edit the values of these items.

In the documentation, I found so far,

a QTableWidget is consisted of QTableWidgetItems
A QTableWidgetItem is contructed from this function



QTableWidgetItem::QTableWidgetItem ( int type = Type )

which is the int type for double numbers and QStrings? I cannot find any list

Zlatomir
29th January 2011, 18:38
Also it has an overloaded constructor with a QString argument: QTableWidgetItem (http://doc.qt.nokia.com/latest/qtablewidgetitem.html#QTableWidgetItem-2)

Basically what you will do is subclass QTableWidgetItem, and store everything as a QString and then see if it's a double/int value or just a string, or a string that means something (like a formula)

You can download from here (http://www.informit.com/store/product.aspx?isbn=0132354160) the sample code for C++ GUI Programming with Qt4, 2nd Edition, it has an example with that functionality.