![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\qmltype Window \nativetype QQuickWindow \inqmlmodule QtQuick More...
#include <qquickwindow.h>
Classes | |
| struct | GraphicsStateInfo |
| \inmodule QtQuick More... | |
Public Slots | |
| void | update () |
| Schedules the window to render another frame. | |
| void | releaseResources () |
| This function tries to release redundant resources currently held by the QML scene. | |
| Public Slots inherited from QWindow | |
| Q_REVISION (2, 1) void requestActivate() | |
| void | setVisible (bool visible) |
| void | show () |
| Shows the window. | |
| void | hide () |
| Hides the window. | |
| void | showMinimized () |
| Shows the window as minimized. | |
| void | showMaximized () |
| Shows the window as maximized. | |
| void | showFullScreen () |
| Shows the window as fullscreen. | |
| void | showNormal () |
| Shows the window as normal, i.e. | |
| bool | close () |
| Close the window. | |
| void | raise () |
| Raise the window in the windowing system. | |
| void | lower () |
| Lower the window in the windowing system. | |
| bool | startSystemResize (Qt::Edges edges) |
| Start a system-specific resize operation. | |
| bool | startSystemMove () |
| Start a system-specific move operation. | |
| void | setTitle (const QString &) |
| void | setX (int arg) |
| void | setY (int arg) |
| void | setWidth (int arg) |
| void | setHeight (int arg) |
| void | setGeometry (int posx, int posy, int w, int h) |
| Sets the geometry of the window, excluding its window frame, to a rectangle constructed from posx, posy, w and h. | |
| void | setGeometry (const QRect &rect) |
| Sets the geometry of the window, excluding its window frame, to rect. | |
| void | setMinimumWidth (int w) |
| void | setMinimumHeight (int h) |
| void | setMaximumWidth (int w) |
| void | setMaximumHeight (int h) |
| Q_REVISION (2, 1) void alert(int msec) | |
| Q_REVISION (2, 3) void requestUpdate() | |
| Public Slots inherited from QObject | |
| void | deleteLater () |
| \threadsafe | |
Signals | |
| void | frameSwapped () |
| This signal is emitted when a frame has been queued for presenting. | |
| void | sceneGraphInitialized () |
| \qmlsignal QtQuick::Window::frameSwapped() | |
| void | sceneGraphInvalidated () |
| \qmlsignal QtQuick::Window::sceneGraphInitialized() | |
| void | beforeSynchronizing () |
| This signal is emitted before the scene graph is synchronized with the QML state. | |
| Q_REVISION (2, 2) void afterSynchronizing() | |
| void | beforeRendering () |
| \qmlsignal QtQuick::Window::afterSynchronizing() | |
| void | afterRendering () |
| \qmlsignal QtQuick::Window::beforeRendering() | |
| Q_REVISION (2, 2) void afterAnimating() | |
| Q_REVISION (2, 2) void sceneGraphAboutToStop() | |
| Q_REVISION (2, 1) void closing(QQuickCloseEvent *close) | |
| void | colorChanged (const QColor &) |
| Q_REVISION (2, 1) void activeFocusItemChanged() | |
| Q_REVISION(2, 2) void sceneGraphError(QQuickWindow | Q_REVISION (2, 14) void beforeRenderPassRecording() |
| Q_REVISION (2, 14) void afterRenderPassRecording() | |
| Q_REVISION (6, 0) void paletteChanged() | |
| Q_REVISION (6, 0) void paletteCreated() | |
| Q_REVISION (6, 0) void beforeFrameBegin() | |
| Q_REVISION (6, 0) void afterFrameEnd() | |
| Q_REVISION (6, 11) void devicePixelRatioChanged() | |
| Signals inherited from QWindow | |
| void | screenChanged (QScreen *screen) |
| This signal is emitted when a window's screen changes, either by being set explicitly with setScreen(), or automatically when the window's screen is removed. | |
| void | modalityChanged (Qt::WindowModality modality) |
| This signal is emitted when the Qwindow::modality property changes to modality. | |
| Q_REVISION(6, 10) void flagsChanged(Qt void | windowStateChanged (Qt::WindowState windowState) |
| This signal is emitted when the windowState changes, either by being set explicitly with setWindowStates(), or automatically when the user clicks one of the titlebar buttons or by other means. | |
| Q_REVISION (2, 2) void windowTitleChanged(const QString &title) | |
| void | xChanged (int arg) |
| void | yChanged (int arg) |
| void | widthChanged (int arg) |
| void | heightChanged (int arg) |
| void | minimumWidthChanged (int arg) |
| void | minimumHeightChanged (int arg) |
| void | maximumWidthChanged (int arg) |
| void | maximumHeightChanged (int arg) |
| Q_REVISION (6, 9) void safeAreaMarginsChanged(QMargins arg) | |
| void | visibleChanged (bool arg) |
| Q_REVISION(2, 1) void visibilityChanged(QWindow | Q_REVISION (2, 1) void activeChanged() |
| void | contentOrientationChanged (Qt::ScreenOrientation orientation) |
| void | focusObjectChanged (QObject *object) |
| This signal is emitted when the final receiver of events tied to focus is changed to object. | |
| Q_REVISION (2, 1) void opacityChanged(qreal opacity) | |
| Q_REVISION (2, 13) void transientParentChanged(QWindow *transientParent) | |
| Signals inherited from QObject | |
| void | destroyed (QObject *=nullptr) |
| This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
| void | objectNameChanged (const QString &objectName, QPrivateSignal) |
| This signal is emitted after the object's name has been changed. | |
Public Member Functions | |
| QQuickWindow (QWindow *parent=nullptr) | |
| \qmlmethod void Window::startSystemMove() | |
| QQuickWindow (QQuickRenderControl *renderControl) | |
| Constructs a window for displaying a QML scene, whose rendering will be controlled by the control object. | |
| ~QQuickWindow () override | |
| Destroys the window. | |
| QQuickItem * | contentItem () const |
| QQuickItem * | activeFocusItem () const |
| QObject * | focusObject () const override |
| QQuickItem * | mouseGrabberItem () const |
| QImage | grabWindow () |
| Grabs the contents of the window and returns it as an image. | |
| void | setRenderTarget (const QQuickRenderTarget &target) |
| \qmlsignal QtQuick::Window::closing(CloseEvent close) | |
| QQuickRenderTarget | renderTarget () const |
| const GraphicsStateInfo & | graphicsStateInfo () |
| \variable QQuickWindow::GraphicsStateInfo::currentFrameSlot | |
| void | beginExternalCommands () |
| When mixing raw graphics (OpenGL, Vulkan, Metal, etc.) commands with scene graph rendering, it is necessary to call this function before recording commands to the command buffer used by the scene graph to render its main render pass. | |
| void | endExternalCommands () |
| When mixing raw graphics (OpenGL, Vulkan, Metal, etc.) commands with scene graph rendering, it is necessary to call this function after recording commands to the command buffer used by the scene graph to render its main render pass. | |
| QQmlIncubationController * | incubationController () const |
| Returns an incubation controller that splices incubation between frames for this window. | |
| QSGTexture * | createTextureFromImage (const QImage &image) const |
| \qmlsignal QtQuick::Window::sceneGraphAboutToStop() | |
| QSGTexture * | createTextureFromImage (const QImage &image, CreateTextureOptions options) const |
| Creates a new QSGTexture from the supplied image. | |
| QSGTexture * | createTextureFromRhiTexture (QRhiTexture *texture, CreateTextureOptions options={}) const |
| Creates a new QSGTexture from the supplied texture. | |
| void | setColor (const QColor &color) |
| QColor | color () const |
| void | setPersistentGraphics (bool persistent) |
| Sets whether the graphics resources (graphics device or context, swapchain, buffers, textures) should be preserved, and cannot be released until the last window is deleted, to persistent. | |
| bool | isPersistentGraphics () const |
| Returns whether essential graphics resources can be released during the lifetime of the QQuickWindow. | |
| void | setPersistentSceneGraph (bool persistent) |
| Sets whether the scene graph nodes and resources are persistent. | |
| bool | isPersistentSceneGraph () const |
| Returns whether the scene graph nodes and resources can be released during the lifetime of this QQuickWindow. | |
| bool | isSceneGraphInitialized () const |
| Returns true if the scene graph has been initialized; otherwise returns false. | |
| void | scheduleRenderJob (QRunnable *job, RenderStage schedule) |
| qreal | effectiveDevicePixelRatio () const |
| Returns the device pixel ratio for this window. | |
| QSGRendererInterface * | rendererInterface () const |
| void | setGraphicsDevice (const QQuickGraphicsDevice &device) |
| QQuickGraphicsDevice | graphicsDevice () const |
| void | setGraphicsConfiguration (const QQuickGraphicsConfiguration &config) |
| Sets the graphics configuration for this window. | |
| QQuickGraphicsConfiguration | graphicsConfiguration () const |
| QSGRectangleNode * | createRectangleNode () const |
| Creates a simple rectangle node. | |
| QSGImageNode * | createImageNode () const |
| Creates a simple image node. | |
| QSGNinePatchNode * | createNinePatchNode () const |
| Creates a nine patch node. | |
| QSGTextNode * | createTextNode () const |
| Creates a text node. | |
| QRhi * | rhi () const |
| QRhiSwapChain * | swapChain () const |
| Public Member Functions inherited from QObject | |
| Q_INVOKABLE | QObject (QObject *parent=nullptr) |
| Constructs an object with parent object parent. | |
| virtual | ~QObject () |
| Destroys the object, deleting all its child objects. | |
| virtual bool | eventFilter (QObject *watched, QEvent *event) |
| Filters events if this object has been installed as an event filter for the watched object. | |
| QString | objectName () const |
| Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
| Sets the object's name to name. | |
| void | setObjectName (QAnyStringView name) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| QBindable< QString > | bindableObjectName () |
| bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. | |
| bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false. | |
| bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false. | |
| bool | isQmlObjectType () const |
| Returns whether the object has been created by the QML engine or ownership has been explicitly set via QJSEngine::setObjectOwnership(). | |
| bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false. | |
| bool | blockSignals (bool b) noexcept |
| If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
| QThread * | thread () const |
| Returns the thread in which the object lives. | |
| bool | moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL) |
Changes the thread affinity for this object and its children and returns true on success. | |
| int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
| This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
| int | startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
| void | killTimer (int id) |
| Kills the timer with timer identifier, id. | |
| void | killTimer (Qt::TimerId id) |
| template<typename T> | |
| T | findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
| Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
| template<typename T> | |
| QList< T > | findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
| Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
| template<typename T> | |
| T | findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename T> | |
| QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| const QObjectList & | children () const |
| Returns a list of child objects. | |
| void | setParent (QObject *parent) |
| Makes the object a child of parent. | |
| void | installEventFilter (QObject *filterObj) |
| Installs an event filter filterObj on this object. | |
| void | removeEventFilter (QObject *obj) |
| Removes an event filter object obj from this object. | |
| QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
| bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const |
| bool | disconnect (const QObject *receiver, const char *member=nullptr) const |
| void | dumpObjectTree () const |
| Dumps a tree of children to the debug output. | |
| void | dumpObjectInfo () const |
| Dumps information about signal connections, etc. | |
| bool | setProperty (const char *name, const QVariant &value) |
| Sets the value of the object's name property to value. | |
| bool | setProperty (const char *name, QVariant &&value) |
| QVariant | property (const char *name) const |
| Returns the value of the object's name property. | |
| QList< QByteArray > | dynamicPropertyNames () const |
| QBindingStorage * | bindingStorage () |
| const QBindingStorage * | bindingStorage () const |
| QObject * | parent () const |
| Returns a pointer to the parent object. | |
| bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. | |
| Public Member Functions inherited from QSurface | |
| virtual | ~QSurface () |
| Destroys the surface. | |
| SurfaceClass | surfaceClass () const |
| Returns the surface class of this surface. | |
| virtual QPlatformSurface * | surfaceHandle () const =0 |
| Returns a handle to the platform-specific implementation of the surface. | |
| bool | supportsOpenGL () const |
| Returns true if the surface is OpenGL compatible and can be used in conjunction with QOpenGLContext; otherwise returns false. | |
Static Public Member Functions | |
| static bool | hasDefaultAlphaBuffer () |
| Returns whether to use alpha transparency on newly created windows. | |
| static void | setDefaultAlphaBuffer (bool useAlpha) |
| useAlpha specifies whether to use alpha transparency on newly created windows. | |
| static void | setGraphicsApi (QSGRendererInterface::GraphicsApi api) |
| Requests the specified graphics api. | |
| static QSGRendererInterface::GraphicsApi | graphicsApi () |
| static void | setSceneGraphBackend (const QString &backend) |
| Requests a Qt Quick scenegraph backend. | |
| static QString | sceneGraphBackend () |
| Returns the requested Qt Quick scenegraph backend. | |
| static TextRenderType | textRenderType () |
| static void | setTextRenderType (TextRenderType renderType) |
| Static Public Member Functions inherited from QObject | |
| static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
| \threadsafe | |
| static QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
| template<typename Func1, typename Func2> | |
| static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
| template<typename Func1, typename Func2> | |
| static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
| static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
| \threadsafe | |
| static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
| static bool | disconnect (const QMetaObject::Connection &) |
| Disconnect a connection. | |
| template<typename Func1, typename Func2> | |
| static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot) |
| template<typename Func1> | |
| static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero) |
Protected Member Functions | |
| QQuickWindow (QQuickWindowPrivate &dd, QWindow *parent=nullptr) | |
| QQuickWindow (QQuickWindowPrivate &dd, QQuickRenderControl *control) | |
| void | exposeEvent (QExposeEvent *) override |
| \reimp | |
| void | resizeEvent (QResizeEvent *) override |
| \reimp | |
| void | showEvent (QShowEvent *) override |
| \reimp | |
| void | hideEvent (QHideEvent *) override |
| \reimp | |
| void | closeEvent (QCloseEvent *) override |
| \reimp | |
| void | focusInEvent (QFocusEvent *) override |
| \reimp | |
| void | focusOutEvent (QFocusEvent *) override |
| \reimp | |
| bool | event (QEvent *) override |
| \reimp | |
| void | keyPressEvent (QKeyEvent *) override |
| \reimp | |
| void | keyReleaseEvent (QKeyEvent *) override |
| \reimp | |
| void | mousePressEvent (QMouseEvent *) override |
| \reimp | |
| void | mouseReleaseEvent (QMouseEvent *) override |
| \reimp | |
| void | mouseDoubleClickEvent (QMouseEvent *) override |
| \reimp | |
| void | mouseMoveEvent (QMouseEvent *) override |
| \reimp | |
| Protected Member Functions inherited from QWindow | |
| virtual void | paintEvent (QPaintEvent *) |
| The paint event (ev) is sent by the window system whenever an area of the window needs a repaint, for example when initially showing the window, or due to parts of the window being uncovered by moving another window. | |
| virtual void | moveEvent (QMoveEvent *) |
| Override this to handle window move events (ev). | |
| virtual void | touchEvent (QTouchEvent *) |
| Override this to handle touch events (ev). | |
| virtual bool | nativeEvent (const QByteArray &eventType, void *message, qintptr *result) |
| Override this to handle platform dependent events. | |
| QWindow (QWindowPrivate &dd, QWindow *parent) | |
| Creates a window as a child of the given parent window with the dd private implementation. | |
| Protected Member Functions inherited from QObject | |
| QObject * | sender () const |
| Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
| int | senderSignalIndex () const |
| int | receivers (const char *signal) const |
| Returns the number of receivers connected to the signal. | |
| bool | isSignalConnected (const QMetaMethod &signal) const |
| virtual void | timerEvent (QTimerEvent *event) |
| This event handler can be reimplemented in a subclass to receive timer events for the object. | |
| virtual void | childEvent (QChildEvent *event) |
| This event handler can be reimplemented in a subclass to receive child events. | |
| virtual void | customEvent (QEvent *event) |
| This event handler can be reimplemented in a subclass to receive custom events. | |
| virtual void | connectNotify (const QMetaMethod &signal) |
| virtual void | disconnectNotify (const QMetaMethod &signal) |
| QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
| Protected Member Functions inherited from QSurface | |
| QSurface (SurfaceClass type) | |
| Creates a surface with the given type. | |
Properties | |
| QColor | color |
| \qmlproperty color Window::color | |
| QQuickItem * | contentItem |
| \qmlattachedproperty Item Window::contentItem | |
| QQuickItem * | activeFocusItem |
The item which currently has active focus or null if there is no item with active focus. | |
| Properties inherited from QWindow | |
| QString | title |
| the window's title in the windowing system | |
| Qt::WindowModality | modality |
| the modality of the window | |
| Qt::WindowFlags | flags |
| the window flags of the window | |
| int | x |
| the x position of the window's geometry | |
| int | y |
| the y position of the window's geometry | |
| int | width |
| the width of the window's geometry | |
| int | height |
| the height of the window's geometry | |
| int | minimumWidth |
| the minimum width of the window's geometry | |
| int | minimumHeight |
| the minimum height of the window's geometry | |
| int | maximumWidth |
| the maximum width of the window's geometry | |
| int | maximumHeight |
| the maximum height of the window's geometry | |
| bool | visible |
| whether the window is visible or not | |
| bool | active |
| the active status of the window | |
| Visibility | visibility |
| the screen-occupation state of the window | |
| Qt::ScreenOrientation | contentOrientation |
| the orientation of the window's contents | |
| qreal | opacity |
| The opacity of the window in the windowing system. | |
| Properties inherited from QObject | |
| QString | objectName |
| the name of this object | |
Friends | |
| class | QQuickItem |
| class | QQuickItemPrivate |
| class | QQuickWidget |
| class | QQuickRenderControl |
| class | QQuickAnimatorController |
| class | QQuickWidgetPrivate |
| class | QQuickDeliveryAgentPrivate |
| QQmlInfo | operator<< (QQmlInfo info, const QQuickWindow *window) |
Additional Inherited Members | |
| Protected Attributes inherited from QObject | |
| QScopedPointer< QObjectData > | d_ptr |
| Protected Attributes inherited from QSurface | |
| SurfaceClass | m_type |
| QSurfacePrivate * | m_reserved |
| Related Symbols inherited from QObject | |
| template< class T > T | qobject_cast (const QObject *object) |
| Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
| template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
| template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
| QObjectList | |
| \macro Q_CLASSINFO(Name, Value) | |
\qmltype Window \nativetype QQuickWindow \inqmlmodule QtQuick
Creates a new top-level window.
The Window object creates a new top-level window for a Qt Quick scene. It automatically sets up the window for use with {QtQuick} graphical types.
A Window can be declared inside an Item or inside another Window, in which case the inner Window will automatically become "transient for" the outer Window, with the outer Window as its \l transientParent. Most platforms will show the Window centered upon the outer window in this case, and there may be other platform-dependent behaviors, depending also on the \l flags. If the nested window is intended to be a dialog in your application, you should also set \l flags to Qt.Dialog, because some window managers will not provide the centering behavior without that flag.
You can also declare multiple windows inside a top-level \l QtObject, in which case the windows will have no transient relationship.
Alternatively you can set or bind \l x and \l y to position the Window explicitly on the screen.
When the user attempts to close a window, the \l closing signal will be emitted. You can force the window to stay open (for example to prompt the user to save changes) by writing an onClosing handler that sets {close.accepted = false} unless it's safe to close the window (for example, because there are no more unsaved changes).
Definition at line 42 of file qquickwindow.h.
The CreateTextureOption enums are used to customize a texture is wrapped.
\value TextureHasAlphaChannel The texture has an alpha channel and should be drawn using blending.
\value TextureHasMipmaps The texture has mipmaps and can be drawn with mipmapping enabled.
\value TextureOwnsGLTexture As of Qt 6.0, this flag is not used in practice and is ignored. Native graphics resource ownership is not transferable to the wrapping QSGTexture, because Qt Quick may not have the necessary details on how such an object and the associated memory should be freed.
\value TextureCanUseAtlas The image can be uploaded into a texture atlas.
\value TextureIsOpaque The texture will return false for QSGTexture::hasAlphaChannel() and will not be blended. This flag was added in Qt 5.6.
| Enumerator | |
|---|---|
| TextureHasAlphaChannel | |
| TextureHasMipmaps | |
| TextureOwnsGLTexture | |
| TextureCanUseAtlas | |
| TextureIsOpaque | |
Definition at line 60 of file qquickwindow.h.
\qmlproperty Item Window::activeFocusItem
The item which currently has active focus or null if there is no item with active focus.
\qmlattachedproperty Item Window::activeFocusItem
This attached property holds the item which currently has active focus or null if there is no item with active focus. The Window attached property can be attached to any Item.
\qmlproperty bool Window::active
The active status of the window.
\qmlattachedproperty bool Window::active
This attached property tells whether the window is active. The Window attached property can be attached to any Item.
Here is an example which changes a label to show the active state of the window in which it is shown:
\qmlmethod QtQuick::Window::requestActivate()
Requests the window to be activated, i.e. receive keyboard focus.
\qmlmethod QtQuick::Window::alert(int msec)
Causes an alert to be shown for msec milliseconds. If msec is 0 (the default), then the alert is shown indefinitely until the window becomes active again.
In alert state, the window indicates that it demands attention, for example by flashing or bouncing the taskbar entry.
\qmlmethod QtQuick::Window::close()
Closes the window.
When this method is called, or when the user tries to close the window by its title bar button, the \l closing signal will be emitted. If there is no handler, or the handler does not revoke permission to close, the window will subsequently close. If the QGuiApplication::quitOnLastWindowClosed property is true, and there are no other windows open, the application will quit.
\qmlmethod QtQuick::Window::raise()
Raises the window in the windowing system.
Requests that the window be raised to appear above other windows.
\qmlmethod QtQuick::Window::lower()
Lowers the window in the windowing system.
Requests that the window be lowered to appear below other windows.
\qmlmethod QtQuick::Window::show()
Shows the window.
This is equivalent to calling showFullScreen(), showMaximized(), or showNormal(), depending on the platform's default behavior for the window type and flags.
\qmlmethod QtQuick::Window::hide()
Hides the window.
Equivalent to setting \l visible to false or \l visibility to \l {QWindow::}{Hidden}.
\qmlmethod QtQuick::Window::showMinimized()
Shows the window as minimized.
Equivalent to setting \l visibility to \l {QWindow::}{Minimized}.
\qmlmethod QtQuick::Window::showMaximized()
Shows the window as maximized.
Equivalent to setting \l visibility to \l {QWindow::}{Maximized}.
\qmlmethod QtQuick::Window::showFullScreen()
Shows the window as fullscreen.
Equivalent to setting \l visibility to \l {QWindow::}{FullScreen}.
\qmlmethod QtQuick::Window::showNormal()
Shows the window as normal, i.e. neither maximized, minimized, nor fullscreen.
Equivalent to setting \l visibility to \l {QWindow::}{Windowed}.
\value BeforeSynchronizingStage Before synchronization. \value AfterSynchronizingStage After synchronization. \value BeforeRenderingStage Before rendering. \value AfterRenderingStage After rendering. \value AfterSwapStage After the frame is swapped. \value NoStage As soon as possible. This value was added in Qt 5.6.
| Enumerator | |
|---|---|
| BeforeSynchronizingStage | |
| AfterSynchronizingStage | |
| BeforeRenderingStage | |
| AfterRenderingStage | |
| AfterSwapStage | |
| NoStage | |
Definition at line 68 of file qquickwindow.h.
This enum describes the error in a sceneGraphError() signal.
\value ContextNotAvailable graphics context creation failed. This typically means that no suitable OpenGL implementation was found, for example because no graphics drivers are installed and so no OpenGL 2 support is present. On mobile and embedded boards that use OpenGL ES such an error is likely to indicate issues in the windowing system integration and possibly an incorrect configuration of Qt.
| Enumerator | |
|---|---|
| ContextNotAvailable | |
Definition at line 80 of file qquickwindow.h.
This enum describes the default render type of text-like elements in Qt Quick (\l Text, \l TextInput, etc.).
Select NativeTextRendering if you prefer text to look native on the target platform and do not require advanced features such as transformation of the text. Using such features in combination with the NativeTextRendering render type will lend poor and sometimes pixelated results.
Both QtTextRendering and CurveTextRendering are hardware-accelerated techniques. QtTextRendering is the faster of the two, but uses more memory and will exhibit rendering artifacts at large sizes. CurveTextRendering should be considered as an alternative in cases where QtTextRendering does not give good visual results or where reducing graphics memory consumption is a priority.
\value QtTextRendering Use Qt's own rasterization algorithm. \value NativeTextRendering Use the operating system's native rasterizer for text. \value CurveTextRendering Text is rendered using a curve rasterizer running directly on the graphics hardware. (Introduced in Qt 6.7.0.)
| Enumerator | |
|---|---|
| QtTextRendering | |
| NativeTextRendering | |
| CurveTextRendering | |
Definition at line 85 of file qquickwindow.h.
|
explicit |
\qmlmethod void Window::startSystemMove()
Starts a system-specific move operation.
Starts an interactive move operation on the window using platform support. The window follows the mouse cursor until the mouse button is released.
Use this method instead of setPosition, because it allows the window manager to handle snapping, tiling, and related animations. On Wayland, setPosition is not supported, so this is the only way the application can influence the window’s position.
\qmlmethod void Window::startSystemResize(Qt::Edges edges)
Starts a system-specific resize operation.
Starts an interactive resize operation on the window using platform support. The specified edge follows the mouse cursor while dragging.
Use this method instead of setGeometry, because it allows the window manager to handle snapping and resize animations when resizing to screen edges.
edges must be a single edge or a combination of two adjacent edges (a corner). Other values are not allowed.
Constructs a window for displaying a QML scene with parent window parent.
Definition at line 1178 of file qquickwindow.cpp.
|
explicit |
Constructs a window for displaying a QML scene, whose rendering will be controlled by the control object.
Please refer to QQuickRenderControl's documentation for more information.
Definition at line 1202 of file qquickwindow.cpp.
|
override |
Destroys the window.
Definition at line 1222 of file qquickwindow.cpp.
|
protected |
Definition at line 1188 of file qquickwindow.cpp.
|
protected |
Definition at line 1212 of file qquickwindow.cpp.
| QQuickItem * QQuickWindow::activeFocusItem | ( | ) | const |
Definition at line 1438 of file qquickwindow.cpp.
|
signal |
\qmlsignal QtQuick::Window::beforeRendering()
The signal is emitted after scene graph has added its commands to the command buffer, which is not yet submitted to the graphics queue. If desired, the slot function connected to this signal can query native resources, like the command buffer, before via QSGRendererInterface. Note however that the render pass (or passes) are already recorded at this point and it is not possible to add more commands within the scenegraph's pass. Instead, use afterRenderPassRecording() for that. This signal has therefore limited use in Qt 6, unlike in Qt 5. Rather, it is the combination of beforeRendering() and beforeRenderPassRecording(), or beforeRendering() and afterRenderPassRecording(), that is typically used to achieve under- or overlaying of the custom rendering.
|
signal |
\qmlsignal QtQuick::Window::afterSynchronizing()
This signal is emitted after the preparations for the frame have been done, meaning there is a command buffer in recording mode, where applicable. If desired, the slot function connected to this signal can query native resources like the command before via QSGRendererInterface. Note however that the recording of the main render pass is not yet started at this point and it is not possible to add commands within that pass. Starting a pass means clearing the color, depth, and stencil buffers so it is not possible to achieve an underlay type of rendering by just connecting to this signal. Rather, connect to beforeRenderPassRecording(). However, connecting to this signal is still important if the recording of copy type of commands is desired since those cannot be enqueued within a render pass.
|
signal |
This signal is emitted before the scene graph is synchronized with the QML state.
Even though the signal is emitted from the scene graph rendering thread, the GUI thread is guaranteed to be blocked, like it is in QQuickItem::updatePaintNode(). Therefore, it is safe to access GUI thread thread data in a slot or lambda that is connected with Qt::DirectConnection.
This signal can be used to do any preparation required before calls to QQuickItem::updatePaintNode().
When using OpenGL, the QOpenGLContext used for rendering by the scene graph will be bound at this point.
| void QQuickWindow::beginExternalCommands | ( | ) |
When mixing raw graphics (OpenGL, Vulkan, Metal, etc.) commands with scene graph rendering, it is necessary to call this function before recording commands to the command buffer used by the scene graph to render its main render pass.
This is to avoid clobbering state.
In practice this function is often called from a slot connected to the beforeRenderPassRecording() or afterRenderPassRecording() signals.
The function does not need to be called when recording commands to the application's own command buffer (such as, a VkCommandBuffer or MTLCommandBuffer + MTLRenderCommandEncoder created and managed by the application, not retrieved from the scene graph). With graphics APIs where no native command buffer concept is exposed (OpenGL, Direct 3D 11), beginExternalCommands() and endExternalCommands() together provide a replacement for the Qt 5 resetOpenGLState() function.
Calling this function and endExternalCommands() is not necessary within the \l{QSGRenderNode::render()}{render()} implementation of a QSGRenderNode because the scene graph performs the necessary steps implicitly for render nodes.
Native graphics objects (such as, graphics device, command buffer or encoder) are accessible via QSGRendererInterface::getResource().
Definition at line 3528 of file qquickwindow.cpp.
|
overrideprotectedvirtual |
| QColor QQuickWindow::color | ( | ) | const |
Definition at line 3384 of file qquickwindow.cpp.
| QQuickItem * QQuickWindow::contentItem | ( | ) | const |
Definition at line 1423 of file qquickwindow.cpp.
| QSGImageNode * QQuickWindow::createImageNode | ( | ) | const |
Creates a simple image node.
When the scenegraph is not initialized, the return value is null.
This is cross-backend alternative to constructing a QSGSimpleTextureNode directly.
Definition at line 4522 of file qquickwindow.cpp.
| QSGNinePatchNode * QQuickWindow::createNinePatchNode | ( | ) | const |
Creates a nine patch node.
When the scenegraph is not initialized, the return value is null.
Definition at line 4533 of file qquickwindow.cpp.
| QSGRectangleNode * QQuickWindow::createRectangleNode | ( | ) | const |
Creates a simple rectangle node.
When the scenegraph is not initialized, the return value is null.
This is cross-backend alternative to constructing a QSGSimpleRectNode directly.
Definition at line 4508 of file qquickwindow.cpp.
| QSGTextNode * QQuickWindow::createTextNode | ( | ) | const |
Creates a text node.
When the scenegraph is not initialized, the return value is null.
Definition at line 4494 of file qquickwindow.cpp.
| QSGTexture * QQuickWindow::createTextureFromImage | ( | const QImage & | image | ) | const |
\qmlsignal QtQuick::Window::sceneGraphAboutToStop()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 3211 of file qquickwindow.cpp.
| QSGTexture * QQuickWindow::createTextureFromImage | ( | const QImage & | image, |
| CreateTextureOptions | options ) const |
Creates a new QSGTexture from the supplied image.
If the image has an alpha channel, the corresponding texture will have an alpha channel.
The caller of the function is responsible for deleting the returned texture. The underlying native texture object is then destroyed together with the QSGTexture.
When options contains TextureCanUseAtlas, the engine may put the image into a texture atlas. Textures in an atlas need to rely on QSGTexture::normalizedTextureSubRect() for their geometry and will not support QSGTexture::Repeat. Other values from CreateTextureOption are ignored.
When options contains TextureIsOpaque, the engine will create an RGB texture which returns false for QSGTexture::hasAlphaChannel(). Opaque textures will in most cases be faster to render. When this flag is not set, the texture will have an alpha channel based on the image's format.
When options contains TextureHasMipmaps, the engine will create a texture which can use mipmap filtering. Mipmapped textures can not be in an atlas.
Setting TextureHasAlphaChannel in options serves no purpose for this function since assuming an alpha channel and blending is the default. To opt out, set TextureIsOpaque.
When the scene graph uses OpenGL, the returned texture will be using GL_TEXTURE_2D as texture target and GL_RGBA as internal format. With other graphics APIs, the texture format is typically RGBA8. Reimplement QSGTexture to create textures with different parameters.
This function can be called from both the main and the render thread.
Definition at line 3262 of file qquickwindow.cpp.
| QSGTexture * QQuickWindow::createTextureFromRhiTexture | ( | QRhiTexture * | texture, |
| CreateTextureOptions | options = {} ) const |
Creates a new QSGTexture from the supplied texture.
Use options to customize the texture attributes. Only the TextureHasAlphaChannel flag is taken into account by this function. When set, the resulting QSGTexture is always treated by the scene graph renderer as needing blending. For textures that are fully opaque, not setting the flag can save the cost of performing alpha blending during rendering. The flag has no direct correspondence to the \l{QRhiTexture::format()}{format} of the QRhiTexture, i.e. not setting the flag while having a texture format such as the commonly used \l QRhiTexture::RGBA8 is perfectly normal.
Mipmapping is not controlled by options since texture is already created and has the presence or lack of mipmaps baked in.
The returned QSGTexture owns the QRhiTexture, meaning texture is destroyed together with the returned QSGTexture.
If texture owns its underlying native graphics resources (OpenGL texture object, Vulkan image, etc.), that depends on how the QRhiTexture was created (\l{QRhiTexture::create()} or \l{QRhiTexture::createFrom()}), and that is not controlled or changed by this function.
Definition at line 3307 of file qquickwindow.cpp.
| qreal QQuickWindow::effectiveDevicePixelRatio | ( | ) | const |
Returns the device pixel ratio for this window.
This is different from QWindow::devicePixelRatio() in that it supports redirected rendering via QQuickRenderControl and QQuickRenderTarget. When using a QQuickRenderControl, the QQuickWindow is often not fully created, meaning it is never shown and there is no underlying native window created in the windowing system. As a result, querying properties like the device pixel ratio cannot give correct results. This function takes into account both QQuickRenderControl::renderWindowFor() and QQuickRenderTarget::devicePixelRatio(). When no redirection is in effect, the result is same as QWindow::devicePixelRatio().
Definition at line 4123 of file qquickwindow.cpp.
| void QQuickWindow::endExternalCommands | ( | ) |
When mixing raw graphics (OpenGL, Vulkan, Metal, etc.) commands with scene graph rendering, it is necessary to call this function after recording commands to the command buffer used by the scene graph to render its main render pass.
This is to avoid clobbering state.
In practice this function is often called from a slot connected to the beforeRenderPassRecording() or afterRenderPassRecording() signals.
The function does not need to be called when recording commands to the application's own command buffer (such as, a VkCommandBuffer or MTLCommandBuffer + MTLRenderCommandEncoder created and managed by the application, not retrieved from the scene graph). With graphics APIs where no native command buffer concept is exposed (OpenGL, Direct 3D 11), beginExternalCommands() and endExternalCommands() together provide a replacement for the Qt 5 resetOpenGLState() function.
Calling this function and beginExternalCommands() is not necessary within the \l{QSGRenderNode::render()}{render()} implementation of a QSGRenderNode because the scene graph performs the necessary steps implicitly for render nodes.
Definition at line 3565 of file qquickwindow.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QWindow.
Reimplemented in QQuickWindowQmlImpl.
Definition at line 1461 of file qquickwindow.cpp.
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
|
overridevirtual |
|
overrideprotectedvirtual |
|
signal |
This signal is emitted when a frame has been queued for presenting.
With vertical synchronization enabled the signal is emitted at most once per vsync interval in a continuously animating scene.
This signal will be emitted from the scene graph rendering thread.
| QImage QQuickWindow::grabWindow | ( | ) |
Grabs the contents of the window and returns it as an image.
It is possible to call the grabWindow() function when the window is not visible. This requires that the window is \l{QWindow::create()} {created} and has a valid size and that no other QQuickWindow instances are rendering in the same process.
software backend is in use. This is because when redirecting the output to an application-managed graphics resource (such as, a texture) by using QQuickRenderControl and setRenderTarget(), the application is better suited for managing and executing an eventual read back operation, since it is in full control of the resource to begin with.Definition at line 2767 of file qquickwindow.cpp.
|
static |
The standard way to query the API used by the scene graph is to use QSGRendererInterface::graphicsApi() once the scene graph has initialized, for example when or after the sceneGraphInitialized() signal is emitted. In that case one gets the true, real result, because then it is known that everything was initialized correctly using that graphics API.
This is not always convenient. If the application needs to set up external frameworks, or needs to work with setGraphicsDevice() in a manner that depends on the scene graph's built in API selection logic, it is not always feasiable to defer such operations until after the QQuickWindow has been made visible or QQuickRenderControl::initialize() has been called.
Therefore, this static function is provided as a counterpart to setGraphicsApi(): it can be called at any time, and the result reflects what API the scene graph would choose if it was initialized at the point of the call.
Definition at line 4307 of file qquickwindow.cpp.
| QQuickGraphicsConfiguration QQuickWindow::graphicsConfiguration | ( | ) | const |
Definition at line 4482 of file qquickwindow.cpp.
| QQuickGraphicsDevice QQuickWindow::graphicsDevice | ( | ) | const |
Definition at line 4435 of file qquickwindow.cpp.
| const QQuickWindow::GraphicsStateInfo & QQuickWindow::graphicsStateInfo | ( | ) |
\variable QQuickWindow::GraphicsStateInfo::currentFrameSlot
the current frame slot index while recording a frame.
When the scenegraph renders with lower level 3D APIs such as Vulkan or Metal, it is the Qt's responsibility to ensure blocking whenever starting a new frame and finding the CPU is already a certain number of frames ahead of the GPU (because the command buffer submitted in frame no. {current} - {FramesInFlight} has not yet completed). With other graphics APIs, such as OpenGL or Direct 3D 11 this level of control is not exposed to the API client but rather handled by the implementation of the graphics API.
By extension, this also means that the appropriate double (or triple) buffering of resources, such as buffers, is up to the graphics API client to manage. Most commonly, a uniform buffer where the data changes between frames cannot simply change its contents when submitting a frame, given that the frame may still be active ("in flight") when starting to record the next frame. To avoid stalling the pipeline, one way is to have multiple buffers (and memory allocations) under the hood, thus realizing at least a double buffered scheme for such resources.
Applications that integrate rendering done directly with a graphics API such as Vulkan may want to perform a similar double or triple buffering of their own graphics resources, in a way that is compatible with the Qt rendering engine's frame submission process. That then involves knowing the values for the maximum number of in-flight frames (which is typically 2 or 3) and the current frame slot index, which is a number running 0, 1, .., FramesInFlight-1, and then wrapping around. The former is exposed in the \l{QQuickWindow::GraphicsStateInfo::framesInFlight}{framesInFlight} variable. The latter, current index, is this value.
For an example of using these values in practice, refer to the {Scene Graph
\variable QQuickWindow::GraphicsStateInfo::framesInFlight
the maximum number of frames kept in flight.
See \l{QQuickWindow::GraphicsStateInfo::currentFrameSlot}{currentFrameSlot} for a detailed description.
Definition at line 3477 of file qquickwindow.cpp.
|
static |
Returns whether to use alpha transparency on newly created windows.
Definition at line 3395 of file qquickwindow.cpp.
|
overrideprotectedvirtual |
| QQmlIncubationController * QQuickWindow::incubationController | ( | ) | const |
Returns an incubation controller that splices incubation between frames for this window.
QQuickView automatically installs this controller for you, otherwise you will need to install it yourself using \l{QQmlEngine::setIncubationController()}.
The controller is owned by the window and will be destroyed when the window is deleted.
Definition at line 2825 of file qquickwindow.cpp.
| bool QQuickWindow::isPersistentGraphics | ( | ) | const |
Returns whether essential graphics resources can be released during the lifetime of the QQuickWindow.
Definition at line 1354 of file qquickwindow.cpp.
| bool QQuickWindow::isPersistentSceneGraph | ( | ) | const |
Returns whether the scene graph nodes and resources can be released during the lifetime of this QQuickWindow.
Definition at line 1400 of file qquickwindow.cpp.
| bool QQuickWindow::isSceneGraphInitialized | ( | ) | const |
Returns true if the scene graph has been initialized; otherwise returns false.
Definition at line 2477 of file qquickwindow.cpp.
|
overrideprotectedvirtual |
| QQuickItem * QQuickWindow::mouseGrabberItem | ( | ) | const |
Definition at line 892 of file qquickwindow.cpp.
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
slot |
This function tries to release redundant resources currently held by the QML scene.
Calling this function requests the scene graph to release cached graphics resources, such as graphics pipeline objects, shader programs, or image data.
Additionally, depending on the render loop in use, this function may also result in the scene graph and all window-related rendering resources to be released. If this happens, the sceneGraphInvalidated() signal will be emitted, allowing users to clean up their own graphics resources. The setPersistentGraphics() and setPersistentSceneGraph() functions can be used to prevent this from happening, if handling the cleanup is not feasible in the application, at the cost of higher memory usage.
Definition at line 1296 of file qquickwindow.cpp.
| QSGRendererInterface * QQuickWindow::rendererInterface | ( | ) | const |
Definition at line 4157 of file qquickwindow.cpp.
| QQuickRenderTarget QQuickWindow::renderTarget | ( | ) | const |
Definition at line 2699 of file qquickwindow.cpp.
|
overrideprotectedvirtual |
| QRhi * QQuickWindow::rhi | ( | ) | const |
Available only when the window is using Qt's 3D API and shading language abstractions, meaning the result is always null when using the software adaptation.
The result is valid only when rendering has been initialized, which is indicated by the emission of the sceneGraphInitialized() signal. Before that point, the returned value is null. With a regular, on-screen QQuickWindow scenegraph initialization typically happens when the native window gets exposed (shown) the first time. When using QQuickRenderControl, initialization is done in the explicit \l{QQuickRenderControl::initialize()}{initialize()} call.
In practice this function is a shortcut to querying the QRhi via the QSGRendererInterface.
Definition at line 4190 of file qquickwindow.cpp.
|
static |
Returns the requested Qt Quick scenegraph backend.
{QT_QUICK_BACKEND} environment variable after a QQuickWindow has been constructed.Definition at line 4353 of file qquickwindow.cpp.
|
signal |
\qmlsignal QtQuick::Window::frameSwapped()
This signal is emitted when a frame has been queued for presenting. With vertical synchronization enabled the signal is emitted at most once per vsync interval in a continuously animating scene.
This signal is emitted when the scene graph has been initialized.
This signal will be emitted from the scene graph rendering thread.
|
signal |
\qmlsignal QtQuick::Window::sceneGraphInitialized()
This signal is emitted when the scene graph has been invalidated.
This signal implies that the graphics rendering context used has been invalidated and all user resources tied to that context should be released.
When rendering with OpenGL, the QOpenGLContext of this window will be bound when this function is called. The only exception is if the native OpenGL has been destroyed outside Qt's control, for instance through EGL_CONTEXT_LOST.
This signal will be emitted from the scene graph rendering thread.
| void QQuickWindow::scheduleRenderJob | ( | QRunnable * | job, |
| RenderStage | stage ) |
Schedules job to run when the rendering of this window reaches the given stage.
This is a convenience to the equivalent signals in QQuickWindow for "one shot" tasks.
The window takes ownership over job and will delete it when the job is completed.
If rendering is shut down before job has a chance to run, the job will be run and then deleted as part of the scene graph cleanup. If the window is never shown and no rendering happens before the QQuickWindow is destroyed, all pending jobs will be destroyed without their run() method being called.
If the rendering is happening on a different thread, then the job will happen on the rendering thread.
If stage is \l NoStage, job will be run at the earliest opportunity whenever the render thread is not busy rendering a frame. If the window is not exposed, and is not renderable, at the time the job is either posted or handled, the job is deleted without executing the run() method. If a non-threaded renderer is in use, the run() method of the job is executed synchronously. When rendering with OpenGL, the OpenGL context is changed to the renderer's context before executing any job, including \l NoStage jobs.
Definition at line 4042 of file qquickwindow.cpp.
Definition at line 3365 of file qquickwindow.cpp.
|
static |
useAlpha specifies whether to use alpha transparency on newly created windows.
In any application which expects to create translucent windows, it's necessary to set this to true before creating the first QQuickWindow. The default value is false.
Definition at line 3409 of file qquickwindow.cpp.
|
static |
Requests the specified graphics api.
When the built-in, default graphics adaptation is used, api specifies which graphics API (OpenGL, Vulkan, Metal, or Direct3D) the scene graph should use to render. In addition, the software backend is built-in as well, and can be requested by setting api to QSGRendererInterface::Software.
Unlike setSceneGraphBackend(), which can only be used to request a given backend (shipped either built-in or installed as dynamically loaded plugins), this function works with the higher level concept of graphics APIs. It covers the backends that ship with Qt Quick, and thus have corresponding values in the QSGRendererInterface::GraphicsApi enum.
When this function is not called at all, and the equivalent environment variable {QSG_RHI_BACKEND} is not set either, the scene graph will choose the graphics API to use based on the platform.
This function becomes important in applications that are only prepared for rendering with a given API. For example, if there is native OpenGL or Vulkan rendering done by the application, it will want to ensure Qt Quick is rendering using OpenGL or Vulkan too. Such applications are expected to call this function early in their main() function.
To query what graphics API the scene graph is using to render, QSGRendererInterface::graphicsApi() after the scene graph \l{QQuickWindow::isSceneGraphInitialized()}{has initialized}, which typically happens either when the window becomes visible for the first time, or when QQuickRenderControl::initialize() is called.
To switch back to the default behavior, where the scene graph chooses a graphics API based on the platform and other conditions, set api to QSGRendererInterface::Unknown.
Definition at line 4258 of file qquickwindow.cpp.
| void QQuickWindow::setGraphicsConfiguration | ( | const QQuickGraphicsConfiguration & | config | ) |
Sets the graphics configuration for this window.
config contains various settings that may be taken into account by the scene graph when initializing the underlying graphics devices and contexts.
Such additional configuration, specifying for example what device extensions to enable for Vulkan, becomes relevant and essential when integrating native graphics rendering code that relies on certain extensions. The same is true when integrating with an external 3D or VR engines, such as OpenXR.
QQuickGraphicsConfiguration instances are implicitly shared, copyable, and can be passed by value.
Definition at line 4468 of file qquickwindow.cpp.
| void QQuickWindow::setGraphicsDevice | ( | const QQuickGraphicsDevice & | device | ) |
Sets the graphics device objects for this window. The scenegraph will use existing device, physical device, and other objects specified by \a device instead of creating new ones. This function is very often used in combination with QQuickRenderControl and setRenderTarget(), in order to redirect Qt Quick rendering into a texture. A default constructed QQuickGraphicsDevice does not change the default behavior in any way. Once a \a device created via one of the QQuickGraphicsDevice factory functions, such as, QQuickGraphicsDevice::fromDeviceObjects(), is passed in, and the scenegraph uses a matching graphics API (with the example of fromDeviceObjects(), that would be Vulkan), the scenegraph will use the existing device objects (such as, the \c VkPhysicalDevice, \c VkDevice, and graphics queue family index, in case of Vulkan) encapsulated by the QQuickGraphicsDevice. This allows using the same device, and so sharing resources, such as buffers and textures, between Qt Quick and native rendering engines. \warning This function can only be called before initializing the scenegraph and will have no effect if called afterwards. In practice this typically means calling it right before QQuickRenderControl::initialize(). As an example, this time with Direct3D, the typical usage is expected to be the following: \badcode
native graphics resources set up by a custom D3D rendering engine ID3D11Device *device; ID3D11DeviceContext *context; ID3D11Texture2D *texture; ... now to redirect Qt Quick content into 'texture' we could do the following: QQuickRenderControl *renderControl = new QQuickRenderControl; QQuickWindow *window = new QQuickWindow(renderControl); // this window will never be shown on-screen ... window->setGraphicsDevice(QQuickGraphicsDevice::fromDeviceAndContext(device, context)); renderControl->initialize(); window->setRenderTarget(QQuickRenderTarget::fromD3D11Texture(texture, textureSize); ...
The key aspect of using this function is to ensure that resources or handles to resources, such as texture in the above example, are visible to and usable by both the external rendering engine and the scenegraph renderer. This requires using the same graphics device (or with OpenGL, OpenGL context).
QQuickGraphicsDevice instances are implicitly shared, copyable, and can be passed by value. They do not own the associated native objects (such as, the ID3D11Device in the example).
Definition at line 4421 of file qquickwindow.cpp.
| void QQuickWindow::setPersistentGraphics | ( | bool | persistent | ) |
Sets whether the graphics resources (graphics device or context, swapchain, buffers, textures) should be preserved, and cannot be released until the last window is deleted, to persistent.
The default value is true.
When calling releaseResources(), or when the window gets hidden (more specifically, not renderable), some render loops have the possibility to release all, not just the cached, graphics resources. This can free up memory temporarily, but it also means the rendering engine will have to do a full, potentially costly reinitialization of the resources when the window needs to render again.
Definition at line 1337 of file qquickwindow.cpp.
| void QQuickWindow::setPersistentSceneGraph | ( | bool | persistent | ) |
Sets whether the scene graph nodes and resources are persistent.
Persistent means the nodes and resources cannot be released. The default value is true.
When calling releaseResources(), when the window gets hidden (more specifically, not renderable), some render loops have the possibility to release the scene graph nodes and related graphics resources. This frees up memory temporarily, but will also mean the scene graph has to be rebuilt when the window renders next time.
Definition at line 1384 of file qquickwindow.cpp.
| void QQuickWindow::setRenderTarget | ( | const QQuickRenderTarget & | target | ) |
\qmlsignal QtQuick::Window::closing(CloseEvent close)
This signal is emitted when the user tries to close the window.
This signal includes a close parameter. The {close.accepted} property is true by default so that the window is allowed to close; but you can implement an onClosing handler and set {close.accepted = false} if you need to do something else before the window can be closed.
Sets the render target for this window to be target.
A QQuickRenderTarget serves as an opaque handle for a renderable native object, most commonly a 2D texture, and associated metadata, such as the size in pixels.
A default constructed QQuickRenderTarget means no redirection. A valid target, created via one of the static QQuickRenderTarget factory functions, on the other hand, enables redirection of the rendering of the Qt Quick scene: it will no longer target the color buffers for the surface associated with the window, but rather the textures or other graphics objects specified in target.
For example, assuming the scenegraph is using Vulkan to render, one can redirect its output into a VkImage. For graphics APIs like Vulkan, the image layout must be provided as well. QQuickRenderTarget instances are implicitly shared and are copyable and can be passed by value. They do not own the associated native objects (such as, the VkImage in the example), however.
\badcode QQuickRenderTarget rt = QQuickRenderTarget::fromVulkanImage(vulkanImage, VK_IMAGE_LAYOUT_PREINITIALIZED, pixelSize); quickWindow->setRenderTarget(rt);
This function is very often used in combination with QQuickRenderControl and an invisible QQuickWindow, in order to render Qt Quick content into a texture, without creating an on-screen native window for this QQuickWindow.
When the desired target, or associated data, such as the size, changes, call this function with a new QQuickRenderTarget. Constructing QQuickRenderTarget instances and calling this function is cheap, but be aware that setting a new target with a different native object or other data may lead to potentially expensive initialization steps when the scenegraph is about to render the next frame. Therefore change the target only when necessary.
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL when rendering a frame.Definition at line 2682 of file qquickwindow.cpp.
Requests a Qt Quick scenegraph backend.
Backends can either be built-in or be installed in form of dynamically loaded plugins.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
See \l{Switch Between Adaptations in Your Application} for more information about the list of backends. If backend is invalid or an error occurs, the request is ignored.
QT_QUICK_BACKEND or QMLSCENE_DEVICE environment variables. However, this API is safer to use in applications that spawn other processes as there is no need to worry about environment inheritance.Definition at line 4336 of file qquickwindow.cpp.
|
static |
Sets the default render type of text-like elements in Qt Quick to renderType.
Definition at line 4562 of file qquickwindow.cpp.
|
overrideprotectedvirtual |
| QRhiSwapChain * QQuickWindow::swapChain | ( | ) | const |
basic or threaded) will have a swapchain. Otherwise the returned value is null. For example, the result is always null when the window is used with QQuickRenderControl.Definition at line 4206 of file qquickwindow.cpp.
|
static |
Returns the render type of text-like elements in Qt Quick. The default is QQuickWindow::QtTextRendering.
Definition at line 4547 of file qquickwindow.cpp.
|
slot |
Schedules the window to render another frame.
Calling QQuickWindow::update() differs from QQuickItem::update() in that it always triggers a repaint, regardless of changes in the underlying scene graph or not.
Definition at line 376 of file qquickwindow.cpp.
|
friend |
Definition at line 242 of file qquickwindow.h.
|
friend |
Definition at line 253 of file qquickwindow.h.
|
friend |
Definition at line 255 of file qquickwindow.h.
|
friend |
Definition at line 249 of file qquickwindow.h.
|
friend |
Definition at line 250 of file qquickwindow.h.
|
friend |
Definition at line 252 of file qquickwindow.h.
|
friend |
Definition at line 251 of file qquickwindow.h.
|
friend |
Definition at line 254 of file qquickwindow.h.
|
read |
The item which currently has active focus or null if there is no item with active focus.
Definition at line 48 of file qquickwindow.h.
|
readwrite |
\qmlproperty color Window::color
The background color for the window.
Setting this property is more efficient than using a separate Rectangle.
"transparent" or to a color with alpha translucency, you should also set suitable \l flags such as {flags: Qt.FramelessWindowHint}. Otherwise, window translucency may not be enabled consistently on all platforms.The color used to clear the color buffer at the beginning of each frame.
By default, the clear color is white.
Definition at line 46 of file qquickwindow.h.
|
read |
\qmlattachedproperty Item Window::contentItem
This attached property holds the invisible root item of the scene or null if the item is not in a window. The Window attached property can be attached to any Item.
The invisible root item of the scene.
A QQuickWindow always has a single invisible root item containing all of its content. To add items to this window, reparent the items to the contentItem or to an existing item in the scene.
Definition at line 47 of file qquickwindow.h.