I design GUI in Qt Designer, then I load UI-file in my Puthon3 script with the loadUiType method:
class Main(QMainWindow, uic.loadUiType("adc_main_form.ui")[0]):
def __init__(self):
super(Main, self).__init__()
self.setupUi(self)
All works fine. Then I make a little revolution in my form design and it includes a lot of renaming. So I take that UI-file of Qt Designer (XML file) and edit it in a text editor. Maybe I make some typo mistakes. Now I get a message during the start of Python script, on the line self.setupUi(self):
File "string", line 671, in setupUi
TypeError: argument 1 has unexpected type 'QRadioButton'
So, some goes wrong in the process of importing the XML file. But the error type tells me not enough to find the error.
I double check all my QRadioButton widgets. No idea.
I open Ui with the Designer - it opens without error messages.
I convert UI into PY (pyiuc5) - no errors.
The .ui file is here.
What can be the way to find the error in such a closed process as setupUI?
Look at the output generated by
pyuic5, at line 671. It should be inside thesetupUimethod. That's what the error is referring to.uic.loadUiTypeis generating a Python file on-the-fly. You then attempt to execute it, and it fails at runtime.Nitpick: Try removing all of the connections from the .ui file. They don't belong there and make the code much harder to maintain, unless the connections are between widgets within the same file. Simply name
MainWindowslots in the following format: on_WIDGET_SIGNAL, where WIDGET is the name of the widget, and SIGNAL is the name of the signal, e.g.on_setADC1_clicked.