[PyQt] PyQt5.uic.loadUi sometimes fails when connecting signals
phil at riverbankcomputing.com
Wed Aug 7 16:56:21 BST 2013
On Tue, 30 Jul 2013 23:25:17 +0100, Roger Leigh <rleigh at debian.org> wrote:
> Hi all,
> I'm getting this error when I use loadUi():
> Traceback (most recent call last):
> File "./testui", line 26, in <module>
> t = Test()
> File "./testui", line 13, in __init__
> self.ui = uic.loadUi("test-broken.ui", self)
> File "/usr/lib/python3/dist-packages/PyQt5/uic/__init__.py", line 224,
> in loadUi
> return DynamicUILoader(package).loadUi(uifile, baseinstance,
> File "/usr/lib/python3/dist-packages/PyQt5/uic/Loader/loader.py", line
> 72, in loadUi
> return self.parse(filename, resource_suffix, basedir)
> File "/usr/lib/python3/dist-packages/PyQt5/uic/uiparser.py", line 931,
> in parse
> File "/usr/lib/python3/dist-packages/PyQt5/uic/uiparser.py", line 856,
> in createConnections
> SystemError: error return without exception set
> I've narrowed this down to occuring when I've added custom slots in
> the ui designer. However, it doesn't always occur, and I can't see
> any obvious reasons for failure.
> I've attached the most minimal testcase I can make. The testui
> program just loads one of the two attached .ui files. One works,
> one fails. The only difference is one line which changes which
> slot gets used. However, both slots are absolutely identical,
> and I can't see any reason for the failure unless either of the
> names is somehow "special".
> The code from which the testcase was derived is here:
> (ogcalc-ui, ogcalc.ui, SpinBoxEntry.py). In this example both
> the reset and calculate callbacks cause the failure; removing the
> signal connection for both makes the UI load. But if I remove
> widgets from the UI to get to the minimal example above, it
> eventually will start working by the time I'm down to the
> minimal example above.
> Being relatively new to both Qt and PyQt, I'm unsure if this isn't
> me doing something wrong, but I can't see anything obviously bad
> here so I'm wondering if I'm tripping over some odd edge case in
> how the signal autoconnection works. Either way, I'd be very
> keen to understand what's going wrong here.
> I'm using Python 3.3/Qt 5.1/PyQt 5.0 on Debian (unstable, amd64).
...in case this hasn't already been answered...
The problem is that your UI has a button called reset, and your
QMainWindow has a slot called reset. The way that loadUi works means that
your UI and QMainWindow are the same object. Just rename either the slot or
The null exception (rather than something more meaningful) is a bug which
(I think) is fixed.
More information about the PyQt