ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

What does python_qt_binding.loadUi's 3rd arg do in PyQt binding?

asked 2013-02-26 13:29:52 -0500

130s gravatar image

updated 2014-01-28 17:15:26 -0500

ngrennan gravatar image

For example, in rqt_bag loadUi takes a python dictionary as its 3rd arg like this:

ui_file = os.path.join(rp.get_path('rqt_bag'), 'resource', 'bag_widget.ui')
loadUi(ui_file, self, {'BagGraphicsView': BagGraphicsView})

Now tracking back loadUi, what PySide binding does makes sense looking at source code -- it uses dictionary "as dictionary":

def loadUi(uifile, baseinstance=None, custom_widgets=None):
    from PySide.QtUiTools import QUiLoader
    from PySide.QtCore import QMetaObject
        :
        def createWidget(self, class_name, parent=None, name=''):
            # don't create the top-level widget, if a base instance is set
            if self._base_instance is not None and parent is None:
                return self._base_instance

            if class_name in self._custom_widgets:
                widget = self._custom_widgets[class_name](parent)

But what about PyQt binding?

def loadUi(uifile, baseinstance=None, custom_widgets=None):
    from PyQt4 import uic
    return uic.loadUi(uifile, baseinstance=baseinstance)

Just ignoring? If so, what's the purpose of letting PySide binding have 3rd arg?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-02-26 16:56:33 -0500

Dirk Thomas gravatar image

PyQt uses the "promoted classes" specified in the UI file and there does not need the 3rd argument. PySide on the other hand does not support that, so you have to explicitly pass the mapping to the loadUi function.

edit flag offensive delete link more

Comments

I see. Given that PySide requires the 3rd arg to incorporate custom classes, I think python_qt_binding.loadUi as an API should obligate the 3rd arg. I'll open a ticket.

130s gravatar image 130s  ( 2013-02-27 10:02:57 -0500 )edit
1

This was certainly true for PySide 1.0.6, but has anyone checked if it changed in more recent versions?

Dorian Scholz gravatar image Dorian Scholz  ( 2013-02-27 22:24:35 -0500 )edit

Ticketed. Let's move further discussion there.

130s gravatar image 130s  ( 2013-02-28 05:58:30 -0500 )edit

Question Tools

Stats

Asked: 2013-02-26 13:29:52 -0500

Seen: 816 times

Last updated: Feb 26 '13