Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquick3dxrruntimeinfo.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
8#include <QtQuick/QQuickWindow>
9#include <rhi/qrhi.h>
10
11#if defined(Q_OS_VISIONOS)
12#include "visionos/qquick3dxrmanager_visionos_p.h"
13#else
14#include "openxr/qquick3dxrmanager_openxr_p.h"
15#endif
16
18
19/*!
20 \qmltype XrRuntimeInfo
21 \inherits Item
22 \inqmlmodule QtQuick3D.Xr
23 \brief Displays information about the XR runtime.
24
25 This type provides information about the XR runtime, including enabled
26 extensions, runtime name, version, graphics API name, and whether multi-view
27 rendering is supported.
28
29 \note This type is automatically created by an \l XrView, and it can not be
30 manually created.
31*/
32
33QQuick3DXrRuntimeInfo::QQuick3DXrRuntimeInfo(QQuick3DXrManager *manager, QObject *parent)
34 : QObject(parent),
35 m_xrmanager(manager)
36{
37}
38
39/*!
40 \qmlproperty list<string> XrRuntimeInfo::enabledExtensions
41 \brief A list of enabled XR extensions.
42 \readonly
43
44 This property holds a QStringList containing the names of the
45 XR extensions that are currently enabled for the runtime.
46
47 \note This list may vary depending on the runtime implementation and can be
48 empty.
49*/
50
51QStringList QQuick3DXrRuntimeInfo::enabledExtensions() const
52{
53 QQuick3DXrManagerPrivate *manager = QQuick3DXrManagerPrivate::get(m_xrmanager);
54 return manager ? manager->enabledExtensions() : QStringList{};
55}
56
57/*!
58 \qmlproperty string XrRuntimeInfo::runtimeName
59 \brief The name of the XR runtime.
60 \readonly
61
62 This property provides the human-readable name of the XR runtime being
63 used.
64*/
65
66QString QQuick3DXrRuntimeInfo::runtimeName() const
67{
68 QQuick3DXrManagerPrivate *manager = QQuick3DXrManagerPrivate::get(m_xrmanager);
69 return manager ? manager->runtimeName() : QString{};
70}
71
72/*!
73 \qmlproperty string XrRuntimeInfo::runtimeVersion
74 \brief The version of the XR runtime.
75 \readonly
76
77 This property holds the version string of the XR runtime
78 (for example, "1.0.0").
79*/
80
81QString QQuick3DXrRuntimeInfo::runtimeVersion() const
82{
83 QQuick3DXrManagerPrivate *manager = QQuick3DXrManagerPrivate::get(m_xrmanager);
84 return manager ? manager->runtimeVersion().toString() : QString{};
85}
86
87/*!
88 \qmlproperty string XrRuntimeInfo::graphicsApiName
89 \brief The name of the graphics API used by the XR runtime.
90 \readonly
91
92 This property holds the name of the graphics API (for example, "Vulkan") that the
93 XR runtime is utilizing.
94*/
95
96QString QQuick3DXrRuntimeInfo::graphicsApiName() const
97{
98 // This matches what Qt Quick's GraphicsInfo would expose to QML, but that
99 // does not provide a string. We have seen way too many switch statements
100 // in JS for this. So, have a string property here and call it a day.
101 if (m_xrmanager->isValid() && m_xrmanager->m_quickWindow) {
102 QRhi *rhi = m_xrmanager->m_quickWindow->rhi();
103 if (rhi)
104 return QString::fromLatin1(rhi->backendName());
105 }
106 return QLatin1String("Unknown");
107}
108
109QT_END_NAMESPACE
Combined button and popup list for selecting options.