A class for applying a
QFileSelectorto QML file loading. 更多 …
def
selector
()
def
setExtraSelectors
(strings)
def
setExtraSelectors
(strings)
def
setSelector
(selector)
QQmlFileSelectorwill automatically apply aQFileSelectorto 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.pngIn 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
QQmlFileSelectoris set on the engine, the old one will be replaced. Useget()to query or use the existing instance.
QQmlFileSelector
(
engine
[
,
parent=None
]
)
¶
- param parent
QObject- param engine
创建新
QQmlFileSelector
with parent object
parent
, which includes its own
QFileSelector
.
engine
是
QQmlEngine
you wish to apply file selectors to. It will also take ownership of the
QQmlFileSelector
.
PySide2.QtQml.QQmlFileSelector.
get
(
arg__1
)
¶
arg__1
–
QQmlEngine
Gets the
QQmlFileSelector
currently active on the target
engine
.
PySide2.QtQml.QQmlFileSelector.
selector
(
)
¶
QFileSelector
返回
QFileSelector
instance used by the
QQmlFileSelector
.
另请参阅
PySide2.QtQml.QQmlFileSelector.
setExtraSelectors
(
strings
)
¶
strings – 字符串列表
PySide2.QtQml.QQmlFileSelector.
setExtraSelectors
(
strings
)
¶
strings – 字符串列表
PySide2.QtQml.QQmlFileSelector.
setSelector
(
selector
)
¶
selector
–
QFileSelector
设置
QFileSelector
instance for use by the
QQmlFileSelector
to
selector
.
QQmlFileSelector
does not take ownership of the new
QFileSelector
. To reset
QQmlFileSelector
to use its internal
QFileSelector
instance, call (0).
另请参阅