So I just discovered something which I believe is a bug, but maybe I did something wrong so thought I should post it here.
I designed a GUI using Qt Designer and then loaded that into my interface class using loadUi(). All of that works without any problems. However, then, I added properties to my class: A single property doesn't cause any issues, but as soon as there is more than one, I receive a SystemError:
Traceback (most recent call last):
File "test.py", line 23, in <module>
GUI = MainWindow()
File "test.py", line 9, in __init__
loadUi('../gui/test.ui', self)
File "..\Anaconda3\lib\site-packages\PyQt5\uic\__init__.py", line 226, in loadUi
return DynamicUILoader(package).loadUi(uifile, baseinstance, resource_suffix)
File "..\Anaconda3\lib\site-packages\PyQt5\uic\Loader\loader.py", line 72, in loadUi
return self.parse(filename, resource_suffix, basedir)
File "..\Anaconda3\lib\site-packages\PyQt5\uic\uiparser.py", line 1021, in parse
actor(elem)
File "..\Anaconda3\lib\site-packages\PyQt5\uic\uiparser.py", line 942, in createConnections
QtCore.QMetaObject.connectSlotsByName(self.toplevelWidget)
SystemError: <built-in function connectSlotsByName> returned a result with an error set
The UI that I loaded in this case is a plain QDialog template, nothing else. You can see the contents of test.ui below:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
</widget>
<resources/>
<connections/>
</ui>
Here is the code that created the error:
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from PyQt5.uic import loadUi
class MainWindow(QDialog):
def __init__(self):
super().__init__()
loadUi('../gui/test.ui', self)
self.test = 1
@property
def test2(self):
return self.test
@property
def test3(self):
return self.test
if __name__ == '__main__':
app = QApplication(sys.argv)
GUI = MainWindow()
GUI.show()
sys.exit(app.exec_())
As soon as you remove one of the properties or the loadUi() command, it works again. What is wrong?