spyder-ide / qtpy

Provides an uniform layer to support PyQt5, PySide2, PyQt6, PySide6 with a single codebase
MIT License
987 stars 153 forks source link

PySide6 bug #484

Closed hannesdelbeke closed 7 months ago

hannesdelbeke commented 7 months ago

Hi

I founda bug, and believe it's related to PySide6.7 release. starting an issue here to make others aware since I believe it might affect everyone using PyQt.

TLDR: using from .. import * and certain import orders break in Pyside6.7, and it seems qtpy triggers one of those conditions.

from PySide6 import QtWidgets

app = QtWidgets.QApplication()
window = QtWidgets.QWidget()
layout = QtWidgets.QVBoxLayout()
window.setLayout(layout)
window.show()
app.exec_()

this code throws an error

LogPython: Error: Traceback (most recent call last):
LogPython: Error:   File "<string>", line 1, in <module>
LogPython: Error:   File "D:\Program Files\Epic Games\UE_5.4\Engine\Binaries\ThirdParty\Python3\Win64\Lib\site-packages\plugget_qt\__init__.py", line 20, in test
LogPython: Error:     window.setLayout(layout)
LogPython: Error: TypeError: 'PySide6.QtWidgets.QWidget.setLayout' called with wrong argument types:
LogPython: Error:   PySide6.QtWidgets.QWidget.setLayout(QVBoxLayout)
LogPython: Error: Supported signatures:
LogPython: Error:   PySide6.QtWidgets.QWidget.setLayout(PySide6.QtWidgets.QLayout)
hannesdelbeke commented 7 months ago

for now, to get around this, i replaced this line

import qtpy.QtWidgets as QtWidgets

with

try:
    import PySide6.QtWidgets as QtWidgets
except ImportError:
    import qtpy.QtWidgets as QtWidgets

which resolved my error in my app

LogPython: Error: WARNING:root:settings file not found: 'C:\Users\H\AppData\Roaming\plugget\settings_plugget.json'
LogPython: Error: Traceback (most recent call last):
LogPython: Error:   File "<string>", line 1, in <module>
LogPython: Error:   File "D:\Program Files\Epic Games\UE_5.4\Engine\Binaries\ThirdParty\Python3\Win64\Lib\site-packages\plugget_qt\__init__.py", line 270, in show
LogPython: Error:     window = MainWindow()
LogPython: Error:              ^^^^^^^^^^^^
LogPython: Error:   File "D:\Program Files\Epic Games\UE_5.4\Engine\Binaries\ThirdParty\Python3\Win64\Lib\site-packages\plugget_qt\__init__.py", line 250, in __init__
LogPython: Error:     central_widget = PluggetWidget(parent=self)
LogPython: Error:                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
LogPython: Error:   File "D:\Program Files\Epic Games\UE_5.4\Engine\Binaries\ThirdParty\Python3\Win64\Lib\site-packages\plugget_qt\__init__.py", line 62, in __init__
LogPython: Error:     self.search_widget.setLayout(search_layout)
LogPython: Error: TypeError: 'PySide6.QtWidgets.QWidget.setLayout' called with wrong argument types:
LogPython: Error:   PySide6.QtWidgets.QWidget.setLayout(QVBoxLayout)
LogPython: Error: Supported signatures:
LogPython: Error:   PySide6.QtWidgets.QWidget.setLayout(PySide6.QtWidgets.QLayout)
ccordoba12 commented 7 months ago

Hey @hannesdelbeke, thanks for reporting. This is basically a duplicate of issue #480 and it's not our fault.

It seems PySide 6.7 broke star imports, which is what we use all over the place in this library (instead of importing object by object).