New Update of Qt Creator causes problem with PyQt6.uic
-
Hello I'm currently using PyQt6 for my project. I create and design the ui with Qt Creator and today I updated the QT Creator program but now I having errors. I didn't get any ui errors before update. It works when I'm not doing any alligments but it still a huge problem.
how I load ui:
#imports from PyQt6.QtWidgets import (QApplication, QMainWindow, QTextEdit, QComboBox, QPushButton, QVBoxLayout, QWidget, QHBoxLayout, QLabel, QLineEdit, QMessageBox ,QFileDialog) from PyQt6.QtCore import QThread, pyqtSignal, QTimer from PyQt6 import uic class MainWindow(QMainWindow): def __init__(self): super().__init__() uic.loadUi("ui/main_window.ui",self)
The error that I'm getting:
Traceback (most recent call last): File "c:\Users\baris\Desktop\LAZER\main.py", line 203, in <module> main_window = MainWindow() ^^^^^^^^^^^^ File "c:\Users\baris\Desktop\LAZER\main.py", line 91, in __init__ uic.loadUi("ui/main_window.ui",self) File "C:\Python312\Lib\site-packages\PyQt6\uic\load_ui.py", line 86, in loadUi return DynamicUILoader(package).loadUi(uifile, baseinstance) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\PyQt6\uic\Loader\loader.py", line 62, in loadUi return self.parse(filename) ^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 1014, in parse self._handle_widget(ui_file.widget) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 842, in _handle_widget self.traverseWidgetTree(el) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 280, in createWidget self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 512, in createLayout self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 555, in handleItem self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 512, in createLayout self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 555, in handleItem self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 512, in createLayout self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 555, in handleItem self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 512, in createLayout self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 554, in handleItem elem[0].attrib['layout-position'] = _layout_position(elem) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 88, in _layout_position return (0, _parse_alignment(alignment)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 61, in _parse_alignment _, qt_align = qt_align.split('::') ^^^^^^^^^^^ ValueError: too many values to unpack (expected 2)
As I said I didn't get any problems before QT Creator update.
-
Hello I'm currently using PyQt6 for my project. I create and design the ui with Qt Creator and today I updated the QT Creator program but now I having errors. I didn't get any ui errors before update. It works when I'm not doing any alligments but it still a huge problem.
how I load ui:
#imports from PyQt6.QtWidgets import (QApplication, QMainWindow, QTextEdit, QComboBox, QPushButton, QVBoxLayout, QWidget, QHBoxLayout, QLabel, QLineEdit, QMessageBox ,QFileDialog) from PyQt6.QtCore import QThread, pyqtSignal, QTimer from PyQt6 import uic class MainWindow(QMainWindow): def __init__(self): super().__init__() uic.loadUi("ui/main_window.ui",self)
The error that I'm getting:
Traceback (most recent call last): File "c:\Users\baris\Desktop\LAZER\main.py", line 203, in <module> main_window = MainWindow() ^^^^^^^^^^^^ File "c:\Users\baris\Desktop\LAZER\main.py", line 91, in __init__ uic.loadUi("ui/main_window.ui",self) File "C:\Python312\Lib\site-packages\PyQt6\uic\load_ui.py", line 86, in loadUi return DynamicUILoader(package).loadUi(uifile, baseinstance) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\PyQt6\uic\Loader\loader.py", line 62, in loadUi return self.parse(filename) ^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 1014, in parse self._handle_widget(ui_file.widget) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 842, in _handle_widget self.traverseWidgetTree(el) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 280, in createWidget self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 512, in createLayout self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 555, in handleItem self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 512, in createLayout self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 555, in handleItem self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 512, in createLayout self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 555, in handleItem self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 512, in createLayout self.traverseWidgetTree(elem) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 818, in traverseWidgetTree handler(self, child) File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 554, in handleItem elem[0].attrib['layout-position'] = _layout_position(elem) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 88, in _layout_position return (0, _parse_alignment(alignment)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\PyQt6\uic\uiparser.py", line 61, in _parse_alignment _, qt_align = qt_align.split('::') ^^^^^^^^^^^ ValueError: too many values to unpack (expected 2)
As I said I didn't get any problems before QT Creator update.
@barisubasi
I realize you perceive this as a Creator issue, but it is not clear to me how this can be. Creator is a UI for developing code. The error traceback you show is down in PyQt6, in theuic
module which is attempting to parse your.ui
file. The error is really there....I seem to recall in another thread here than someone may have said that the latest Creator (13/14/15?) now saves the
.ui
file in a newer format than it used to? If so it may be that the PyQtuic
module you have does not handle that or needs updating to a latest version? If you have the.ui
file from before you upgraded Creator compare that against how it is being produced now, is there a difference? I have a feeling this is the issue....?Otherwise you would probably have to contact the PyQt folks since that is where the error lies.
BTW, you should be able to run your Python program quite outside of Creator, and I would expect it to show the same error.
-
@barisubasi
BTW, as a heads-up. You are developing by loading the.ui
file dynamically at runtime, as per e.g. https://www.pythonguis.com/tutorials/pyqt6-first-steps-qt-designer/ Loading the .ui file directly subsection. Unless you have a pathological reason for this approach, do yourself a favour and change over to producing a.py
file from the.ui
as per Converting your .ui file to Python topic there. Similar in https://stackoverflow.com/questions/66613380/downloading-qtdesigner-for-pyqt6-and-converting-ui-file-to-py-file-with-pyuic6. I don't know but I imagine you can set Creator to run this for you automatically whenever the.ui
file is updated.This requires an extra step during development, but in return you get a better development-time experience and a much better interface to the widgets you design: at present I believe you have to call
QObject.findChild(...)
to access any widgets you created, with the Python class generation approach you get variables for each of your widgets.As a side effect this would eliminate the calls to
PyQt6\uic\uiparser.py
where your current error is occurring. Mind you, if I am right about the.ui
file format having changed you are likely to need a newest version ofpyuic6
executable from PyQt, so your issue may need a newer version of PyQt6 (or a downgrade of Creator) in either case.Finally, depending on how big/how committed your project is to PyQt, you might consider moving over to PySide6. When I first started in Qt5 only PyQt5 was "advanced" enough to use for Python, PySide/PySide2 was too "backward". Now PySide6 seems to be just about as good as PyQt6.
-
This is a apparently a consequence of introducing support for fully qualified enums for PySide 6 (see https://lists.qt-project.org/pipermail/development/2023-November/044620.html ). Please ask the PyQt6 developers to adapt to this. pyside6-uic will correctly handle this.