Hi Matteo,

If you check for QTableWidget::item(...) you see that it returns a
QTableWidgetItem*, so that's what you check the type of which you
specified yourself when creating the item. Either construct the items
with an integer you want (this does not need to match the QVariant
types' id)

Or use setData(...) and data() on the item which is used to specify
custom data on the item. If you then use data().type() you will get the
QVariant types' you are looking for.

Cheers
Matthias

On 03/02/2016 03:38 PM, matteo wrote:
> Hi all,
> I'm struggling with a problem in a QGIS plugin.
>
> Very briefly, in Qt Designer I have created a QTableWidget with some
> rows. The first one is filled with some default values (int and floats).
>
> I did not find a way to get a list of the data types in the python script.
>
> This in a piece of code of the plugin:
>
> lst = []
>
> for i in range(self.tableWidget.columnCount()):
>
>       itm = self.tableWidget.item(0,i)
>
>         lst.append(itm.type())
>
> but the lst list is made up by zeros (while it sould contain 2 for
> QVariant.Integers and 6 for QVariant.Double).
>
> Am I missing something?
>
> Thanks to all
>
> Cheers
>
> Matteo
> _______________________________________________
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user

-- 
Matthias Kuhn
OPENGIS.ch - https://www.opengis.ch
Spatial • (Q)GIS • PostGIS • Open Source

_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to