Comments (12)
I came here to see if this was indeed a qtpy issue or a PySide6 issue, and it seems to in fact be some strange interaction:
Even reducing the imports to the strict minimum:
import sys
from PySide6.QtWidgets import QTreeWidget, QTreeWidgetItem, QTextEdit, QListWidget, QSplitter, QWidget, QApplication, QHBoxLayout
class Example(QWidget):
I have a feeling it might be related to: https://bugreports.qt.io/browse/PYSIDE-2675
Will continue to investigate (fyi, I'm not a developer of qtpy, just a mere user trying to help)
from qtpy.
I really think it has something to do with their lazy import structure. The issue I referred to and some notes from https://wiki.qt.io/Qt_for_Python_Development_Notes hint that they are working through a few things with it.
import sys
from PySide6.QtWidgets import QWidget
from qtpy.QtWidgets import *
from qtpy.QtGui import *
from qtpy.QtCore import *
class Example(QWidget):
"works"
So I think it is related to the note:
from qtpy.
So FYI, for my code, I had to add above all other qtpy wigets imports and whatnot
import qtpy
if qtpy.PYSIDE6:
from PySide6.QtWidgets import QWidget
with an adequate note as to when it can be removed. It isn't ideal, but it "works".
from qtpy.
The screenshot of their development notes indicates that * importing may be a source of problems.
This compatibility layer uses star style imports.
from qtpy.
@hmaarrfk, thanks for chiming in and providing additional context for this issue!
I doubt that this is a problem with Qtpy because for the most part it's a wrapper for PySide/PyQt (we patch some objects for compatibility between bindings and versions, but we try to keep that to a minimum).
from qtpy.
So FYI, for my code, I had to add above all other qtpy wigets imports and whatnot
import qtpy if qtpy.PYSIDE6: from PySide6.QtWidgets import QWidgetwith an adequate note as to when it can be removed. It isn't ideal, but it "works".
It should be noted that I'm not lazy importing in production code, just in the example. That said, I suspect the solution you provided will work. Its not ideal, but it should work. I'll have to try it out when I return to the office on Monday.
from qtpy.
I wonder if it works again If one unrolls ALL members that would be imported via *
like:
...
elif PYSIDE6:
import PySide6.QtCore
from PySide6.QtCore import (
ClassInfo, MetaFunction, Property, QAbstractAnimation, QAbstractEventDispatcher,
QAbstractItemModel, QAbstractListModel, QAbstractNativeEventFilter, QAbstractProxyModel,
QAbstractTableModel, QAnimationGroup, QBasicMutex, QBasicTimer, QBitArray, QBuffer,
QByteArray, QByteArrayMatcher, QCborArray, QCborError, QCborKnownTags, QCborMap,
QCborParserError, QCborSimpleType, QCborStreamReader, QCborStreamWriter,
QCborStringResultByteArray, QCborStringResultString, QCborValue, QChildEvent, QCollator,
QCollatorSortKey, QCommandLineOption, QCommandLineParser, QCoreApplication,
QCryptographicHash, QDataStream, QDate ...
(snip from qtpy/QtCore.py)
Probably. I'm not gonna try for my hobby projects (will simply deprecate PySide2 support)
But might be an idea for qtpy (and our wrapper at work)
from qtpy.
The screenshot of their development notes indicates that * importing may be a source of problems.
This compatibility layer uses star style imports.
Ah, my bad, I misread what you'd originally entered.
from qtpy.
Related Issues (20)
- Some compatibility issues when using latest PyQt6 or PySide6 (6.5+) HOT 1
- Type hints not working for `qtpy` specific imports HOT 7
- Try to retrieve `QT_API` from file if not set in env variable HOT 6
- Release QtPy 2.4.0 HOT 1
- Testssuite fails to run: pytest.PytestDeprecationWarning: The hookimpl CovPlugin.pytest_configure_node uses old-style configuration options HOT 2
- Typo causes failed QWebEngineScript with PySide6 HOT 4
- Release QtPy 2.4.1 HOT 1
- Qt namespace is littered with service functions HOT 2
- `uic.py` inconsistencies and logic errors
- Odd code found for `PyQt6`: always raises an exception
- QtBindingsNotFoundError on Importing Spyder with Python 3.11.6 HOT 7
- QMenu.add_action() got an unexpected keyword argument 'shortcut' HOT 3
- Why can't I import QAction normally using qtpy? HOT 1
- Allow to specify Qt version via an environment variable (`QT_VERSION`) HOT 4
- BUG: Incompatible with PySide6 6.7.0 HOT 3
- 30 tests fail HOT 1
- Type stubs? Possible integration with PyQt5-stubs and PySide6-stubs packages? HOT 6
- PySide6 bug HOT 2
- Update tests to be compatible with pytest 8.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qtpy.