Comments (8)
Ah, interesting, I've never used these myself. What do they do?
from qt.py.
They are used to load .ui files made in Qt Designer.
These seem to be the most common modules to use when loading a .ui file:
PyQt4.uic
PySide.QtUiTools.QUiLoader
However, there's an issue with PySide's QUiLoader
which makes it behave differently than PyQt's uic
. When you've loaded the UI using QUiLoader
, you don't access the objects through the expected namespace (if you consider PyQt to be "god"). I believe that could have been why pysideuic
was developed, as it fixes that – but I don't for a fact this was the reasoning on why pysideuic
was made.
Here's an example where I use pysideuic
to load the UI if you're using PySide -- or use PyQt4.uic
if you're using PyQt4. And regardless of choice, you can perform the self.listWidget.addItem('Hello world')
at the end of main.py which would modify the UI (if it has a listWidget).
- All of this is really useful and nice when you jump between Maya, Nuke and PySide/PyQt.
- So far, I can tell that this same behaviour is true for PyQt5/PySide2.
- It's important to note that functions of
PyQt4.uic
andpysideuic
are not the same.
I'm not sure myself if this is a good idea, and I might have a better idea at the end of the week. I'm afraid we may be making code harder to read if we create e.g. PySide.uic
and PySide2.uic
. And especially since they will need a separate module installed (pysideuic
).
Hacketihackhack.
from qt.py.
Here's an example
Isn't there an easier way of doing that? It seems awefully complex.
With PyQt4 there is this.
If we're wrapping any of that, I would expect something along these lines.
from Qt import loadUi
Where loadUi
is our own version and behaves like PySide2.
from qt.py.
It seems awefully complex.
Agreed. But there's no real equivalent of PyQt4.uic.loadUi
in PySide. Instead, you have to use PySide.QtUiTools.QUiLoader
. Which is why I've gone through all that trouble.
PySide.QtUiTools.QUiLoader
works fairly well if you only load one ui file, example here with comparisons to PyQt4.uic.loadUi
.
I'll try to write up an example to show when it'll become problematic with QUiLoader. But I digress somewhat. Since there are multiple choices of .ui loaders to choose between, perhaps it's not a good thing that we choose for the end-user.
I'd like to close my own question with a "no, not right now anyways".
from qt.py.
Agreed. But there's no real equivalent of PyQt4.uic.loadUi in PySide.
Ah, I see.
I'd be fine with a loadUi
convenience function coming from this project, that does what it does for PyQt. That seems like the simplest method.
I'd like to close my own question with a "no, not right now anyways".
Let's keep it open, the question is bound to come up again sooner or later.
from qt.py.
So perhaps it could be interesting to explore after all. I've been tinkering and here's a gist.
Some issues:
- UI file is not loaded into
self
. Instead it is loaded into e.g.self.ui
. - The second UI file cannot be loaded into
self.ui
and any widgets we need to access needs to be moved intoself.ui
manually. - Haven't tested this with PyQt5 as that errors out at the moment #28
from qt.py.
I'll let you decide what's best here, as I don't use this feature.
from qt.py.
Sure, will do. I'll be back with a suggestion/PR.
from qt.py.
Related Issues (20)
- Import QJsonDocument, QJsonParseError from Qt.QtCore is failure HOT 1
- wrapInstance: Search inheritance hierarchy for a suitable class HOT 2
- [HOW TO] Set preferred binding from code before import HOT 2
- name 'QGuiApplication' is not defined HOT 3
- QT-Py internal NEOPixel HOT 5
- _wrapInstance pointer type assert message in Py3 HOT 1
- looks like QtGui.QGuiApplication is not wrapped... HOT 1
- Table Drop Event and loadUi with PySide2 HOT 3
- Add PySide6 support HOT 20
- https://github.com/spyder-ide/qtpy/issues/348 HOT 6
- QtCompat.isValid() Not Available for All Qt Objects HOT 8
- How to add menubar in QT?
- Drop PyQt because it may be illegal to import a GPL lib from a lib under MIT HOT 1
- TypeError: Expected 4 or 5 arguments, got 3. HOT 1
- Is it possible to add support for QIdentityProxyModel HOT 1
- Change of types-PySide2 breaks Python 2 compatibility HOT 10
- TypeError: 'PySide2.QtWidgets.QWidget' called with wrong argument types
- partially initialized module 'Qt' has no attribute 'QtGui' (most likely due to a circular import)
- Convert does not convert files built with pyside2-uic 5.15.2 HOT 1
- signal.connect() TypeError in pyqt5 when signal has an argument HOT 9
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 qt.py.