PythonQt.QtUiTools.QUiLoader
QUiLoader
PythonQtInstanceWrapper object
Native bases: PythonQtInstanceWrapper
Supplemental documentation: Qt 5 reference:
Detailed Description
In addition, you can customize or create your own user interface by deriving your own loader class.
If you have a custom component or an application that embeds Qt Designer, you can also use the QFormBuilder class provided by the QtDesigner module to create user interfaces from UI files.
The QUiLoader class provides a collection of functions allowing you to create widgets based on the information stored in UI files (created with Qt Designer) or available in the specified plugin paths. The specified plugin paths can be retrieved using the pluginPaths() function. Similarly, the contents of a UI file can be retrieved using the load() function. For example:
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
QUiLoader loader;
QFile file(":/forms/myform.ui");
file.open(QFile::ReadOnly);
QWidget *myWidget = loader.load(&file, this);
file.close();
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(myWidget);
setLayout(layout);
}
By including the user interface in the form's resources (myform.qrc), we ensure that
it will be present at run-time:
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/forms">
<file>myform.ui</file>
</qresource>
</RCC>
The availableWidgets() function returns a QStringList with the class names of the widgets available in the specified plugin paths. To create these widgets, simply use the createWidget() function. For example:
QWidget *loadCustomWidget(QWidget *parent)
{
QUiLoader loader;
QWidget *myWidget;
QStringList availableWidgets = loader.availableWidgets();
if (availableWidgets.contains("AnalogClock"))
myWidget = loader.createWidget("AnalogClock", parent);
return myWidget;
}
To make a custom widget available to the loader, you can use the addPluginPath() function; to remove all available widgets, you can call the clearPluginPaths() function.
The createAction(), createActionGroup(), createLayout(), and createWidget() functions are used internally by the QUiLoader class whenever it has to create an action, action group, layout, or widget respectively. For that reason, you can subclass the QUiLoader class and reimplement these functions to intervene the process of constructing a user interface. For example, you might want to have a list of the actions created when loading a form or creating a custom widget.
For a complete example using the QUiLoader class, see the Calculator Builder Example.
Source: https://doc.qt.io/archives/qt-5.15/quiloader.html
Complete member index
Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.
| Member | Kind | Signature | Summary |
|---|---|---|---|
__init__ |
function | (self, *args: Any, **kwargs: Any) -> None |
Native constructor; consult class documentation for supported overloads. (shared captured text) |
addPluginPath |
function | (self, path: str) -> None |
Adds the given path to the list of paths in which the loader will search when locating plugins. |
availableLayouts |
function | (self) -> tuple |
X.availableLayouts() -> tuple |
availableWidgets |
function | (self) -> tuple |
X.availableWidgets() -> tuple |
blockSignals |
function | (self, b: Any) -> bool |
X.blockSignals(b) -> bool (shared captured text) |
childEvent |
function | (self, event: Any) -> Any |
(shared captured text) |
children |
function | (self) -> tuple |
X.children() -> tuple (shared captured text) |
className |
function | (self, *args: Any, **kwargs: Any) -> Any |
Return the classname of the object (shared captured text) |
clearPluginPaths |
function | (self) -> None |
Clears the list of paths in which the loader will search when locating plugins. |
connect |
function | (self, signal: Any, receiver: Any, slot: Any, type: Any) -> bool |
X.connect(signal, receiver, slot, type) -> bool (shared captured text) |
createAction |
function | (self, parent: Any, name: str) -> Any |
X.createAction(parent, name) -> PythonQt.QtGui.QAction |
createActionGroup |
function | (self, parent: Any, name: str) -> Any |
X.createActionGroup(parent, name) -> PythonQt.QtGui.QActionGroup |
createLayout |
function | (self, className: str, parent: Any, name: str) -> Any |
X.createLayout(className, parent, name) -> PythonQt.QtGui.QLayout |
createWidget |
function | (self, className: str, parent: Any, name: str) -> Any |
X.createWidget(className, parent, name) -> PythonQt.QtGui.QWidget |
customEvent |
function | (self, event: Any) -> Any |
(shared captured text) |
delete |
function | (self, *args: Any, **kwargs: Any) -> Any |
Deletes the C++ object (at your own risk, my friend!) (shared captured text) |
deleteLater |
function | (self) -> Any |
(shared captured text) |
destroyed |
function | (self, *args: Any, **kwargs: Any) -> Any |
Native PythonQt.QtUiTools.QUiLoader.destroyed; argument details are not documented. |
disconnect |
function | (self, signal: Any, receiver: Any, slot: Any) -> bool |
X.disconnect(signal, receiver, slot) -> bool (shared captured text) |
dumpObjectInfo |
function | (self) -> Any |
(shared captured text) |
dumpObjectTree |
function | (self) -> Any |
(shared captured text) |
dynamicPropertyNames |
function | (self) -> Any |
(shared captured text) |
errorString |
function | (self) -> str |
X.errorString() -> str |
event |
function | (self, event: Any) -> bool |
X.event(event) -> bool (shared captured text) |
eventFilter |
function | (self, watched: Any, event: Any) -> bool |
X.eventFilter(watched, event) -> bool (shared captured text) |
findChild |
function | (self, type: Any, name: Any) -> Any |
X.findChild(type, name) -> PythonQt.private.QObject (shared captured text) |
findChildren |
function | (self, type: Any, name: Any) -> tuple |
X.findChildren(type, name) -> tuple (shared captured text) |
help |
function | (self, *args: Any, **kwargs: Any) -> Any |
Shows the help of available methods for this class (shared captured text) |
inherits |
function | (self, *args: Any, **kwargs: Any) -> Any |
Returns if the class inherits or is of given type name (shared captured text) |
installEventFilter |
function | (self, filterObj: Any) -> Any |
(shared captured text) |
isLanguageChangeEnabled |
function | (self) -> bool |
X.isLanguageChangeEnabled() -> bool |
isSignalConnected |
function | (self, signal: Any) -> bool |
X.isSignalConnected(signal) -> bool (shared captured text) |
isTranslationEnabled |
function | (self) -> bool |
X.isTranslationEnabled() -> bool |
isWidgetType |
function | (self) -> bool |
X.isWidgetType() -> bool (shared captured text) |
isWindowType |
function | (self) -> bool |
X.isWindowType() -> bool (shared captured text) |
killTimer |
function | (self, id: Any) -> Any |
(shared captured text) |
load |
function | (self, device: Any, parentWidget: Any) -> Any |
X.load(device, parentWidget) -> PythonQt.QtGui.QWidget |
metaObject |
function | (self) -> Any |
X.metaObject() -> PythonQt.QtCore.QMetaObject (shared captured text) |
moveToThread |
function | (self, thread: Any) -> Any |
(shared captured text) |
objectName |
attribute | Any |
(shared captured text) |
objectNameChanged |
function | (self, *args: Any, **kwargs: Any) -> Any |
Native PythonQt.QtUiTools.QUiLoader.objectNameChanged; argument details are not documented. |
parent |
function | (self) -> Any |
X.parent() -> PythonQt.private.QObject (shared captured text) |
pluginPaths |
function | (self) -> tuple |
X.pluginPaths() -> tuple |
property |
function | (self, name: Any) -> Any |
X.property(name) -> object (shared captured text) |
removeEventFilter |
function | (self, obj: Any) -> Any |
(shared captured text) |
sender |
function | (self) -> Any |
X.sender() -> PythonQt.private.QObject (shared captured text) |
senderSignalIndex |
function | (self) -> int |
X.senderSignalIndex() -> int (shared captured text) |
setLanguageChangeEnabled |
function | (self, enabled: bool) -> None |
If enabled is true, user interfaces loaded by this loader will automatically retranslate themselves upon receiving a language change event. |
setObjectName |
function | (self, name: Any) -> Any |
(shared captured text) |
setParent |
function | (self, parent: Any) -> Any |
(shared captured text) |
setProperty |
function | (self, name: Any, value: Any) -> bool |
X.setProperty(name, value) -> bool (shared captured text) |
setTranslationEnabled |
function | (self, enabled: bool) -> None |
|
setWorkingDirectory |
function | (self, dir: Any) -> None |
Sets the working directory of the loader to dir. |
signalsBlocked |
function | (self) -> bool |
X.signalsBlocked() -> bool (shared captured text) |
startTimer |
function | (self, interval: Any, timerType: Any) -> int |
X.startTimer(interval, timerType) -> int (shared captured text) |
thread |
function | (self) -> Any |
(shared captured text) |
timerEvent |
function | (self, event: Any) -> Any |
(shared captured text) |
tr |
function | (self, text: Any, ambig: Any, n: Any) -> str |
X.tr(text, ambig, n) -> str (shared captured text) |
workingDirectory |
function | (self) -> Any |
X.workingDirectory() -> PythonQt.QtCore.QDir |