How to change Python Qt binding?
In rqt
's plugin tutorial in python
, using qt_binding_helper
is recommended/required for making plugin developers not to care which python
- qt
binding to use (namely either PyQt
or PySide
). But looks like qt_binding_helper
internally uses PyQt
by default. How can I change to PySide
?
I tried following and still didn't work as I kind of expected.
from python_qt_binding.QtBindingHelper import select_qt_binding
:
class RealityWidget(QWidget):
def __init__(self, context, node=None):
:
select_qt_binding('pyside') # P.S.2
loadUi(ui_file, self)
P.S.1 The reason I want to use PySide
is first of all I like to avoid GPL
that PyQt
requires (as mentioned in python_qt_binding
's wiki as well). Another trigger is that my code experiences this problem where using PyQt
yields runtime error while PySide
doesn't. This doesn't mean I have to use PySide
but just want to avoid any possible unknown issues.
P.S.2 select_qt_binding
Update 9/17/12) As far as I searched my file system, no module uses python_qt_binding.QtBindingHelper.select_qt_binding
.
__init__.py
in rviz
suggests that:
# Can use the following setattr() call to force one binding or the other.
# setattr(sys, 'SELECT_QT_BINDING', 'pyside')
But tyring to use like this it only fails to show still pyqt
is in use:
import os
import sys
import rospy
import rosnode
setattr(sys, 'SELECT_QT_BINDING', 'pyside')
from qt_gui.qt_binding_helper import loadUi
from python_qt_binding.QtBindingHelper import select_qt_binding, QT_BINDING
from QtGui import QWidget, QTreeWidgetItem
class RealityWidget(QWidget):
def __init__(self, context, node=None):
select_qt_binding('pyside')
print ('QT_BINDING=' + QT_BINDING) # this prints "pyqt"
:
ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'reality.ui')
loadUi(ui_file, self)