You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-9Lines changed: 30 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,11 +122,11 @@ All members of `Qt` stem directly from those available via PySide2, along with t
122
122
123
123
Qt.py also provides compatibility wrappers for critical functionality that differs across bindings, these can be found in the added `QtCompat` submodule.
@@ -148,6 +148,7 @@ These are the publicly facing environment variables that in one way or another a
148
148
|:---------------------|:------|:----------
149
149
| QT_PREFERRED_BINDING | str | Override order and content of binding to try.
150
150
| QT_VERBOSE | bool | Be a little more chatty about what's going on with Qt.py
151
+
| QT_SIP_API_HINT | int | Sets the preferred SIP api version that will be attempted to set.
151
152
152
153
<br>
153
154
@@ -212,21 +213,41 @@ Now you may use the file as you normally would, with Qt.py
212
213
213
214
<br>
214
215
215
-
##### Load Qt Designer files
216
+
##### Loading Qt Designer files
216
217
217
-
The `uic.loadUi` function of PyQt4 and PyQt5 as well as the `QtUiTools.QUiLoader().load` function of PySide/PySide2 are mapped to a convenience function `load_ui`.
218
+
The `uic.loadUi` function of PyQt4 and PyQt5 as well as the `QtUiTools.QUiLoader().load` function of PySide/PySide2 are mapped to a convenience function `loadUi`.
218
219
219
220
```python
220
221
import sys
221
222
from Qt import QtCompat
222
223
223
224
app = QtWidgets.QApplication(sys.argv)
224
-
ui = QtCompat.load_ui(fname="my.ui")
225
+
ui = QtCompat.loadUi(fname="my.ui")
225
226
ui.show()
226
227
app.exec_()
227
228
```
229
+
For `PyQt` bindings it uses their native implementation, whereas for `PySide` bindings it uses our custom implementation borrowed from the [qtpy](https://github.com/spyder-ide/qtpy) project.
230
+
231
+
`loadUi` has two arguments as opposed to the multiple that PyQt ships with. See [here](https://github.com/mottosso/Qt.py/pull/81) for details - in a nutshell, those arguments differ between PyQt and PySide in incompatible ways.
232
+
The second argument is `baseinstance` which allows a ui to be dynamically loaded onto an existing QWidget instance.
`uifile` is the string path to the ui file to load.
239
+
240
+
If `baseinstance` is `None`, the a new instance of the top-level
241
+
widget will be created. Otherwise, the user interface is created within
242
+
the given `baseinstance`. In this case `baseinstance` must be an
243
+
instance of the top-level widget class in the UI file to load, or a
244
+
subclass thereof. In other words, if you've created a `QMainWindow`
245
+
interface in the designer, `baseinstance` must be a `QMainWindow`
246
+
or a subclass thereof, too. You cannot load a `QMainWindow` UI file
247
+
with a plain `QWidget` as `baseinstance`.
228
248
229
-
Please note, `load_ui` has only one argument, whereas the PyQt and PySide equivalent has more. See [here](https://github.com/mottosso/Qt.py/pull/81) for details - in a nutshell, those arguments differ between PyQt and PySide in incompatible ways.
249
+
`loadUi` returns `baseinstance`, if `baseinstance` is provided.
250
+
Otherwise it will return the newly created instance of the user interface.
0 commit comments