- class QQmlFileSelector#
A class for applying a QFileSelector to QML file loading. More…
Synopsis#
Methods#
def
__init__()
def
selector()
def
setSelector()
Static functions#
def
get()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
QQmlFileSelector
will automatically apply a QFileSelector to qml file and asset paths.It is used as follows:
QQmlEngine engine; QQmlFileSelector* selector = new QQmlFileSelector(&engine);
Then you can swap out files like so:
main.qml Component.qml asset.png +unix/Component.qml +mac/asset.png
In this example, main.qml will normally use Component.qml for the Component type. However on a unix platform, the unix selector will be present and the +unix/Component.qml version will be used instead. Note that this acts like swapping out Component.qml with +unix/Component.qml, so when using Component.qml you should not need to alter any paths based on which version was selected.
For example, to pass the “asset.png” file path around you would refer to it just as “asset.png” in all of main.qml, Component.qml, and +linux/Component.qml. It will be replaced with +mac/asset.png on Mac platforms in all cases.
For a list of available selectors, see
QFileSelector
.Your platform may also provide additional selectors for you to use. As specified by QFileSelector, directories used for selection must start with a ‘+’ character, so you will not accidentally trigger this feature unless you have directories with such names inside your project.
If a new
QQmlFileSelector
is set on the engine, the old one will be replaced.- __init__(engine[, parent=None])#
- Parameters:
engine –
QQmlEngine
parent –
QObject
Creates a new
QQmlFileSelector
with parent objectparent
, which includes its own QFileSelector.engine
is theQQmlEngine
you wish to apply file selectors to. It will also take ownership of theQQmlFileSelector
.- static get(arg__1)#
- Parameters:
arg__1 –
QQmlEngine
- Return type:
Note
This function is deprecated.
The file selector should not be accessed after it is set. It may be in use. See below for further details.
Gets the
QQmlFileSelector
currently active on the targetengine
.This method is deprecated. You should not retrieve the files selector from an engine after setting it. It may be in use.
If the
engine
passed here is aQQmlApplicationEngine
that hasn’t loaded any QML files, yet, it will be initialized. Any later calls tosetExtraFileSelectors()
will have no effect.See also
- selector()#
- Return type:
Returns the QFileSelector instance used by the
QQmlFileSelector
.See also
- setExtraSelectors(strings)#
- Parameters:
strings – list of strings
Adds extra selectors contained in
strings
to the current QFileSelector being used. Use this when extra selectors are all you need to avoid having to create your own QFileSelector instance.- setSelector(selector)#
- Parameters:
selector –
QFileSelector
Sets the QFileSelector instance for use by the
QQmlFileSelector
toselector
.QQmlFileSelector
does not take ownership of the new QFileSelector. To resetQQmlFileSelector
to use its internal QFileSelector instance, call setSelector(None
).See also