Robotics StackExchange | Archived questions

python_qt_binding and QStringList,QStringListModel missing

I recently incorporated an Rviz widget into my custom GUI, and the Rviz Python bindings require the use of 'pythonqtbinding' (I used to just directly import PyQt4). Unfortunately, this is causing some problems in the rest of my code. When using from python_qt_binding.QtCore import *, I am now getting a NameError when attempting to create QStringList or QStringListModel objects (NameError: global name 'QStringList' is not defined).

Am I doing something wrong, or am I expected to work around this?

Asked by pgebhard on 2013-10-02 19:27:48 UTC

Comments

Answers

I guess python_qt_binding is not handling these types very well since they are treated special in the bindings. I am not sure if that is easily fixable in python_qt_binding but I have filled a ticket for that: https://github.com/ros-visualization/python_qt_binding/issues/8

For your specific case I would suggest to just use plain Python strings and Python lists of strings. That should work seemless with the QStringListModel API. And in Python 3.x the types QString / QStringList will go away anyway. So it would make your code also more future proof.

Asked by Dirk Thomas on 2013-10-03 13:05:36 UTC

Comments

python_qt_binding uses PyQt4 with SIP API version 2. And for that there are no QString / QStringList types defines anymore. Please see http://qt-project.org/wiki/Differences_Between_PySide_and_PyQt#b7669e9ad9355d8b4e8fdccade317b2b for more information.

Asked by Dirk Thomas on 2013-10-04 15:50:41 UTC