pub struct Window<'a> { /* private fields */ }
Expand description
Notice these docs are heavy WIP and not very relevent yet
A window that is supplied a parent becomes a native child window of their parent window.
An application will typically use QWidget or QQuickView for its UI, and not QWindow directly. Still, it is possible to render directly to a QWindow with QBackingStore or QOpenGLContext, when wanting to keep dependencies to a minimum or when wanting to use OpenGL directly. The Raster Window Example and OpenGL Window Example are useful reference examples for how to render to a QWindow using either approach.
Resource Management
Windows can potentially use a lot of memory. A usual measurement is width times height times color depth. A window might also include multiple buffers to support double and triple buffering, as well as depth and stencil buffers. To release a window’s memory resources, call the destroy() function.
Content Orientation
QWindow has reportContentOrientationChange() that can be used to specify the layout of the window contents in relation to the screen. The content orientation is simply a hint to the windowing system about which orientation the window contents are in. It’s useful when you wish to keep the same window size, but rotate the contents instead, especially when doing rotation animations between different orientations. The windowing system might use this value to determine the layout of system popups or dialogs.
Visibility and Windowing System Exposure
By default, the window is not visible, and you must call setVisible(true), or show() or similar to make it visible. To make a window hidden again, call setVisible(false) or hide(). The visible property describes the state the application wants the window to be in. Depending on the underlying system, a visible window might still not be shown on the screen. It could, for instance, be covered by other opaque windows or moved outside the physical area of the screen. On windowing systems that have exposure notifications, the isExposed() accessor describes whether the window should be treated as directly visible on screen. The exposeEvent() function is called whenever the windows exposure in the windowing system changes. On windowing systems that do not make this information visible to the application, isExposed() will simply return the same value as isVisible().
QWindow::Visibility queried through visibility() is a convenience API combining the functions of visible() and windowStates().
Rendering
There are two Qt APIs that can be used to render content into a window, QBackingStore for rendering with a QPainter and flushing the contents to a window with type QSurface::RasterSurface, and QOpenGLContext for rendering with OpenGL to a window with type QSurface::OpenGLSurface.
The application can start rendering as soon as isExposed() returns true,
and can keep rendering until it isExposed() returns false.
To find out when
isExposed() changes, reimplement exposeEvent(). The window will always get
a resize event before the first expose event.
Initial Geometry
If the window’s width and height are left uninitialized, the window will get a reasonable default geometry from the platform window. If the position is left uninitialized, then the platform window will allow the windowing system to position the window. For example on X11, the window manager usually does some kind of smart positioning to try to avoid having new windows completely obscure existing windows. However setGeometry() initializes both the position and the size, so if you want a fixed size but an automatic position, you should call resize() or setWidth() and setHeight() instead.
Licence
The documentation is an adoption of the original Qt Documentation and provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Implementations
sourceimpl<'a> Window<'a>
impl<'a> Window<'a>
pub fn new() -> Window<'a>
sourcepub fn set_object_surface_type(&self, surface_type: SurfaceType) -> &Self
pub fn set_object_surface_type(&self, surface_type: SurfaceType) -> &Self
Sets the surfaceType of the window.
Specifies whether the window is meant for raster rendering with QBackingStore, or OpenGL rendering with QOpenGLContext.
The surfaceType will be used when the native surface is created in the create() function. Calling this function after the native surface has been created requires calling destroy() and create() to release the old native surface and create a new one.
See also: BackingStore
[OpenGLContext
]
[create()
]
[destroy()
]
sourcepub fn surface_type(&self) -> SurfaceType
pub fn surface_type(&self) -> SurfaceType
Returns the surface type of the window.
See also: [set_surface_type()
]
pub fn is_visible(&self) -> bool
sourcepub fn visibility(&self) -> Visibility
pub fn visibility(&self) -> Visibility
Visibility is whether the window should appear in the windowing system as normal, minimized, maximized, fullscreen or hidden.
To set the visibility to AutomaticVisibility means to give the window a default visible state, which might be fullscreen or windowed depending on the platform. When reading the visibility property you will always get the actual state, never AutomaticVisibility.
pub fn set_visibility(&self, v: Visibility) -> &Self
sourcepub fn create(&self) -> &Self
pub fn create(&self) -> &Self
Allocates the platform resources associated with the window.
It is at this point that the surface format set using setFormat() gets resolved into an actual native surface. However, the window remains hidden until setVisible() is called.
Note that it is not usually necessary to call this function directly, as it will be implicitly called by show(), setVisible(), and other functions that require access to the platform resources.
Call destroy() to free the platform resources if necessary.
See also: [destroy()
]
sourcepub fn win_id(&self) -> u64
pub fn win_id(&self) -> u64
Returns the window’s platform id.
For platforms where this id might be useful, the value returned will uniquely represent the window inside the corresponding screen.
See also: [screen()
]
sourcepub fn parent(&self, mode: AncestorMode) -> Option<Window<'_>>
pub fn parent(&self, mode: AncestorMode) -> Option<Window<'_>>
Returns the parent window, if any.
If mode is IncludeTransients, then the transient parent is returned if there is no parent.
A window without a parent is known as a top level window.
Returns the parent window, if any.
A window without a parent is known as a top level window.
sourcepub fn parent_2(&self) -> Option<Window<'_>>
pub fn parent_2(&self) -> Option<Window<'_>>
Returns the parent window, if any.
If mode is IncludeTransients, then the transient parent is returned if there is no parent.
A window without a parent is known as a top level window.
Returns the parent window, if any.
A window without a parent is known as a top level window.
sourcepub fn set_parent<W: WindowTrait<'a>>(&self, parent: &W) -> &Self
pub fn set_parent<W: WindowTrait<'a>>(&self, parent: &W) -> &Self
Sets the parent Window. This will lead to the windowing system managing the clip of the window, so it will be clipped to the parent window.
Setting parent to be 0 will make the window become a top level window.
If parent is a window created by fromWinId(), then the current window will be embedded inside parent, if the platform supports it.
sourcepub fn is_top_level(&self) -> bool
pub fn is_top_level(&self) -> bool
Returns whether the window is top level, i.e. has no parent window.
sourcepub fn is_modal(&self) -> bool
pub fn is_modal(&self) -> bool
Returns whether the window is modal.
A modal window prevents other windows from getting any input.
See also: Window::modality()
sourcepub fn modality(&self) -> WindowModality
pub fn modality(&self) -> WindowModality
A modal window prevents other windows from receiving input events. Qt supports two types of modality: Qt::WindowModal and Qt::ApplicationModal.
By default, this property is Qt::NonModal
See also: [t::window_modality()
]
This signal is emitted when the Qwindow::modality property changes to modality.
pub fn set_modality(&self, modality: WindowModality) -> &Self
sourcepub fn set_object_format<S: SurfaceFormatTrait<'a>>(&self, format: &S) -> &Self
pub fn set_object_format<S: SurfaceFormatTrait<'a>>(&self, format: &S) -> &Self
Sets the window’s surface format.
The format determines properties such as color depth, alpha, depth and stencil buffer size, etc. For example, to give a window a transparent background (provided that the window system supports compositing, and provided that other content in the window does not make it opaque again):
QSurfaceFormat format;
format.setAlphaBufferSize(8);
window.setFormat(format);
The surface format will be resolved in the create() function. Calling this function after create() has been called will not re-resolve the surface format of the native surface.
When the format is not explicitly set via this function, the format returned by QSurfaceFormat::defaultFormat() will be used. This means that when having multiple windows, individual calls to this function can be replaced by one single call to QSurfaceFormat::setDefaultFormat() before creating the first window.
See also: [create()
]
[destroy()
]
SurfaceFormat::set_default_format
sourcepub fn format(&self) -> SurfaceFormat<'_>
pub fn format(&self) -> SurfaceFormat<'_>
Returns the actual format of this window.
After the window has been created, this function will return the actual surface format of the window. It might differ from the requested format if the requested format could not be fulfilled by the platform. It might also be a superset, for example certain buffer sizes may be larger than requested.
Note: Depending on the platform, certain values in this surface format may still contain the requested values, that is, the values that have been passed to setFormat(). Typical examples are the OpenGL version, profile and options. These may not get updated during create() since these are context specific and a single window may be used together with multiple contexts over its lifetime. Use the QOpenGLContext’s format() instead to query such values.
See also: [create()
]
[requested_format()
]
[OpenGLContext::format
]
sourcepub fn requested_format(&self) -> SurfaceFormat<'_>
pub fn requested_format(&self) -> SurfaceFormat<'_>
Returns the requested surface format of this window.
If the requested format was not supported by the platform implementation, the requestedFormat will differ from the actual window format.
This is the value set with setFormat().
See also: [set_format()
]
[format()
]
pub fn set_flags(&self, flags: WindowFlags) -> &Self
sourcepub fn flags(&self) -> WindowFlags
pub fn flags(&self) -> WindowFlags
The window flags control the window’s appearance in the windowing system, whether it’s a dialog, popup, or a regular window, and whether it should have a title bar, etc.
The actual window flags might differ from the flags set with setFlags() if the requested flags could not be fulfilled.
See also: [set_flag()
]
sourcepub fn title(&self) -> String
pub fn title(&self) -> String
Sets the window flag flag on this window if on is true; otherwise clears the flag.
See also: [set_flags()
]
[flags()
]
[type()
]
Returns the type of the window.
This returns the part of the window flags that represents whether the window is a dialog, tooltip, popup, regular window, etc.
See also: [flags()
]
[set_flags()
]
The window title might appear in the title area of the window decorations, depending on the windowing system and the window flags. It might also be used by the windowing system to identify the window in other contexts, such as in the task switcher.
See also: [flags()
]
pub fn set_opacity(&self, level: f32) -> &Self
sourcepub fn opacity(&self) -> f32
pub fn opacity(&self) -> f32
If the windowing system supports window opacity, this can be used to fade the window in and out, or to make it semitransparent.
A value of 1.0 or above is treated as fully opaque, whereas a value of 0.0 or below is treated as fully transparent. Values inbetween represent varying levels of translucency between the two extremes.
The default value is 1.0.
sourcepub fn set_mask<R: RegionTrait<'a>>(&self, region: &R) -> &Self
pub fn set_mask<R: RegionTrait<'a>>(&self, region: &R) -> &Self
Sets the mask of the window.
The mask is a hint to the windowing system that the application does not want to receive mouse or touch input outside the given region.
The window manager may or may not choose to display any areas of the window not included in the mask, thus it is the application’s responsibility to clear to transparent the areas that are not part of the mask.
sourcepub fn mask(&self) -> Region<'_>
pub fn mask(&self) -> Region<'_>
Returns the mask set on the window.
The mask is a hint to the windowing system that the application does not want to receive mouse or touch input outside the given region.
sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Returns true
if the window should appear active from a style perspective.
This is the case for the window that has input focus as well as windows that are in the same parent / transient parent chain as the focus window.
To get the window that currently has focus, use QGuiApplication::focusWindow().
pub fn report_content_orientation_change(
&self,
orientation: ScreenOrientation
) -> &Self
sourcepub fn content_orientation(&self) -> ScreenOrientation
pub fn content_orientation(&self) -> ScreenOrientation
This is a hint to the window manager in case it needs to display additional content like popups, dialogs, status bars, or similar in relation to the window.
The recommended orientation is QScreen::orientation() but an application doesn’t have to support all possible orientations, and thus can opt to ignore the current screen orientation.
The difference between the window and the content orientation determines how much to rotate the content by. QScreen::angleBetween(), QScreen::transformBetween(), and QScreen::mapBetween() can be used to compute the necessary transform.
The default value is Qt::PrimaryOrientation
sourcepub fn device_pixel_ratio(&self) -> f32
pub fn device_pixel_ratio(&self) -> f32
Returns the ratio between physical pixels and device-independent pixels for the window. This value is dependent on the screen the window is on, and may change when the window is moved.
Common values are 1.0 on normal displays and 2.0 on Apple displays.
Note: For windows not backed by a platform window, meaning that create() was not called, the function will fall back to the associated QScreen’s device pixel ratio.
See also: Screen::device_pixel_ratio
sourcepub fn window_state(&self) -> WindowState
pub fn window_state(&self) -> WindowState
See also: [set_window_state()
]
[window_states()
]
The window can be in a combination of several states. For example, if the window is both minimized and maximized, the window will appear minimized, but clicking on the task bar entry will restore it to the maximized state.
See also: [set_window_states()
]
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.
sourcepub fn window_states(&self) -> WindowStates
pub fn window_states(&self) -> WindowStates
The window can be in a combination of several states. For example, if the window is both minimized and maximized, the window will appear minimized, but clicking on the task bar entry will restore it to the maximized state.
See also: [set_window_states()
]
sourcepub fn set_window_state(&self, state: WindowState) -> &Self
pub fn set_window_state(&self, state: WindowState) -> &Self
The window state represents whether the window appears in the windowing system as maximized, minimized, fullscreen, or normal.
The enum value Qt::WindowActive is not an accepted parameter.
See also: [show_normal()
]
[show_full_screen()
]
[show_minimized()
]
[show_maximized()
]
[set_window_states()
]
The window state represents whether the window appears in the windowing system as maximized, minimized and/or fullscreen.
The window can be in a combination of several states. For example, if the window is both minimized and maximized, the window will appear minimized, but clicking on the task bar entry will restore it to the maximized state.
The enum value Qt::WindowActive should not be set.
See also: [show_normal()
]
[show_full_screen()
]
[show_minimized()
]
[show_maximized()
]
sourcepub fn set_window_states(&self, states: WindowStates) -> &Self
pub fn set_window_states(&self, states: WindowStates) -> &Self
The window state represents whether the window appears in the windowing system as maximized, minimized and/or fullscreen.
The window can be in a combination of several states. For example, if the window is both minimized and maximized, the window will appear minimized, but clicking on the task bar entry will restore it to the maximized state.
The enum value Qt::WindowActive should not be set.
See also: [show_normal()
]
[show_full_screen()
]
[show_minimized()
]
[show_maximized()
]
sourcepub fn set_transient_parent<W: WindowTrait<'a>>(&self, parent: &W) -> &Self
pub fn set_transient_parent<W: WindowTrait<'a>>(&self, parent: &W) -> &Self
Sets the transient parent
This is a hint to the window manager that this window is a dialog or pop-up on behalf of the given window.
In order to cause the window to be centered above its transient parent by
default, depending on the window manager, it may also be necessary to call
setFlags() with a suitable Qt::WindowType
(such as Qt::Dialog).
See also: [transient_parent()
]
[parent()
]
sourcepub fn is_ancestor_of<W: WindowTrait<'a>>(
&self,
child: &W,
mode: AncestorMode
) -> bool
pub fn is_ancestor_of<W: WindowTrait<'a>>(
&self,
child: &W,
mode: AncestorMode
) -> bool
Returns true
if the window is an ancestor of the given child. If mode
is IncludeTransients, then transient parents are also considered ancestors.
sourcepub fn is_exposed(&self) -> bool
pub fn is_exposed(&self) -> bool
Returns if this window is exposed in the windowing system.
When the window is not exposed, it is shown by the application but it is still not showing in the windowing system, so the application should minimize rendering and other graphical activities.
An exposeEvent() is sent every time this value changes.
See also: [expose_event()
]
sourcepub fn minimum_width(&self) -> i32
pub fn minimum_width(&self) -> i32
sourcepub fn minimum_height(&self) -> i32
pub fn minimum_height(&self) -> i32
sourcepub fn maximum_width(&self) -> i32
pub fn maximum_width(&self) -> i32
sourcepub fn maximum_height(&self) -> i32
pub fn maximum_height(&self) -> i32
sourcepub fn minimum_size(&self) -> Size<'_>
pub fn minimum_size(&self) -> Size<'_>
Returns the minimum size of the window.
See also: [set_minimum_size()
]
sourcepub fn maximum_size(&self) -> Size<'_>
pub fn maximum_size(&self) -> Size<'_>
Returns the maximum size of the window.
See also: [set_maximum_size()
]
sourcepub fn base_size(&self) -> Size<'_>
pub fn base_size(&self) -> Size<'_>
Returns the base size of the window.
See also: [set_base_size()
]
sourcepub fn size_increment(&self) -> Size<'_>
pub fn size_increment(&self) -> Size<'_>
Returns the size increment of the window.
See also: [set_size_increment()
]
sourcepub fn set_minimum_size<S: SizeTrait<'a>>(&self, size: &S) -> &Self
pub fn set_minimum_size<S: SizeTrait<'a>>(&self, size: &S) -> &Self
Sets the minimum size of the window.
This is a hint to the window manager to prevent resizing below the specified size.
See also: [set_maximum_size()
]
[minimum_size()
]
sourcepub fn set_maximum_size<S: SizeTrait<'a>>(&self, size: &S) -> &Self
pub fn set_maximum_size<S: SizeTrait<'a>>(&self, size: &S) -> &Self
Sets the maximum size of the window.
This is a hint to the window manager to prevent resizing above the specified size.
See also: [set_minimum_size()
]
[maximum_size()
]
sourcepub fn set_base_size<S: SizeTrait<'a>>(&self, size: &S) -> &Self
pub fn set_base_size<S: SizeTrait<'a>>(&self, size: &S) -> &Self
Sets the base size of the window.
The base size is used to calculate a proper window size if the window defines sizeIncrement().
See also: [set_minimum_size()
]
[set_maximum_size()
]
[set_size_increment()
]
[base_size()
]
sourcepub fn set_size_increment<S: SizeTrait<'a>>(&self, size: &S) -> &Self
pub fn set_size_increment<S: SizeTrait<'a>>(&self, size: &S) -> &Self
Sets the size increment ( size) of the window.
When the user resizes the window, the size will move in steps of sizeIncrement().width() pixels horizontally and sizeIncrement().height() pixels vertically, with baseSize() as the basis.
By default, this property contains a size with zero width and height.
The windowing system might not support size increments.
See also: [set_base_size()
]
[set_minimum_size()
]
[set_maximum_size()
]
sourcepub fn frame_margins(&self) -> Margins<'_>
pub fn frame_margins(&self) -> Margins<'_>
Returns the window frame margins surrounding the window.
See also: [geometry()
]
[frame_geometry()
]
sourcepub fn frame_position(&self) -> Point<'_>
pub fn frame_position(&self) -> Point<'_>
Returns the top left position of the window, including its window frame.
This returns the same value as frameGeometry().topLeft().
See also: [geometry()
]
[frame_geometry()
]
sourcepub fn set_frame_position<P: PointTrait<'a>>(&self, point: &P) -> &Self
pub fn set_frame_position<P: PointTrait<'a>>(&self, point: &P) -> &Self
Sets the upper left position of the window ( point) including its window frame.
The position is in relation to the virtualGeometry() of its screen.
See also: [set_geometry()
]
[frame_geometry()
]
sourcepub fn size(&self) -> Size<'_>
pub fn size(&self) -> Size<'_>
Returns the size increment of the window.
See also: [set_size_increment()
]
See also: [resize()
]
sourcepub fn set_position<P: PointTrait<'a>>(&self, pt: &P) -> &Self
pub fn set_position<P: PointTrait<'a>>(&self, pt: &P) -> &Self
pt
The position is in relation to the virtualGeometry() of its screen.
See also: [position()
]
posx, posy
The position is in relation to the virtualGeometry() of its screen.
See also: [position()
]
sourcepub fn set_position_2(&self, posx: i32, posy: i32) -> &Self
pub fn set_position_2(&self, posx: i32, posy: i32) -> &Self
pt
The position is in relation to the virtualGeometry() of its screen.
See also: [position()
]
posx, posy
The position is in relation to the virtualGeometry() of its screen.
See also: [position()
]
sourcepub fn resize<S: SizeTrait<'a>>(&self, new_size: &S) -> &Self
pub fn resize<S: SizeTrait<'a>>(&self, new_size: &S) -> &Self
set the size of the window, excluding any window frame, to a QSize constructed from width w and height h
See also: [size()
]
[geometry()
]
newSize
See also: [size()
]
[geometry()
]
Override this to handle resize events ( ev).
The resize event is called whenever the window is resized in the windowing system, either directly through the windowing system acknowledging a setGeometry() or resize() request, or indirectly through the user resizing the window manually.
sourcepub fn resize_2(&self, w: i32, h: i32) -> &Self
pub fn resize_2(&self, w: i32, h: i32) -> &Self
set the size of the window, excluding any window frame, to a QSize constructed from width w and height h
See also: [size()
]
[geometry()
]
newSize
See also: [size()
]
[geometry()
]
Override this to handle resize events ( ev).
The resize event is called whenever the window is resized in the windowing system, either directly through the windowing system acknowledging a setGeometry() or resize() request, or indirectly through the user resizing the window manually.
sourcepub fn set_file_path(&self, file_path: &str) -> &Self
pub fn set_file_path(&self, file_path: &str) -> &Self
The windowing system might use filePath to display the path of the document this window is representing in the tile bar.
sourcepub fn set_icon<I: IconTrait<'a>>(&self, icon: &I) -> &Self
pub fn set_icon<I: IconTrait<'a>>(&self, icon: &I) -> &Self
icon in the windowing system
The window icon might be used by the windowing system for example to decorate the window, and/or in the task switcher.
Note: On macOS, the window title bar icon is meant for windows representing documents, and will only show up if a file path is also set.
See also: [set_file_path()
]
sourcepub fn set_keyboard_grab_enabled(&self, grab: bool) -> bool
pub fn set_keyboard_grab_enabled(&self, grab: bool) -> bool
Sets whether keyboard grab should be enabled or not ( grab).
If the return value is true, the window receives all key events until setKeyboardGrabEnabled(false) is called; other windows get no key events at all. Mouse events are not affected. Use setMouseGrabEnabled() if you want to grab that.
See also: [set_mouse_grab_enabled()
]
sourcepub fn set_mouse_grab_enabled(&self, grab: bool) -> bool
pub fn set_mouse_grab_enabled(&self, grab: bool) -> bool
Sets whether mouse grab should be enabled or not ( grab).
If the return value is true, the window receives all mouse events until setMouseGrabEnabled(false) is called; other windows get no mouse events at all. Keyboard events are not affected. Use setKeyboardGrabEnabled() if you want to grab that.
See also: [set_keyboard_grab_enabled()
]
sourcepub fn screen(&self) -> Option<Screen<'_>>
pub fn screen(&self) -> Option<Screen<'_>>
Returns the screen on which the window is shown, or null if there is none.
For child windows, this returns the screen of the corresponding top level window.
See also: [set_screen()
]
[Screen::virtual_siblings
]
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.
sourcepub fn set_screen<S: ScreenTrait<'a>>(&self, screen: &S) -> &Self
pub fn set_screen<S: ScreenTrait<'a>>(&self, screen: &S) -> &Self
Sets the screen on which the window should be shown.
If the window has been created, it will be recreated on the newScreen.
Note: If the screen is part of a virtual desktop of multiple screens, the window will not move automatically to newScreen. To place the window relative to the screen, use the screen’s topLeft() position.
This function only works for top level windows.
See also: [screen()
]
[Screen::virtual_siblings
]
sourcepub fn focus_object(&self) -> Option<Object<'_>>
pub fn focus_object(&self) -> Option<Object<'_>>
This signal is emitted when the final receiver of events tied to focus is changed to object.
See also: [focus_object()
]
Returns the QObject that will be the final receiver of events tied focus, such as key events.
sourcepub fn map_to_global<P: PointTrait<'a>>(&self, pos: &P) -> Point<'_>
pub fn map_to_global<P: PointTrait<'a>>(&self, pos: &P) -> Point<'_>
Translates the window coordinate pos to global screen
coordinates. For example, mapToGlobal(QPoint(0,0))
would give
the global coordinates of the top-left pixel of the window.
See also: [map_from_global()
]
sourcepub fn map_from_global<P: PointTrait<'a>>(&self, pos: &P) -> Point<'_>
pub fn map_from_global<P: PointTrait<'a>>(&self, pos: &P) -> Point<'_>
Translates the global screen coordinate pos to window coordinates.
See also: [map_to_global()
]
sourcepub fn set_cursor<C: CursorTrait<'a>>(&self, arg0: &C) -> &Self
pub fn set_cursor<C: CursorTrait<'a>>(&self, arg0: &C) -> &Self
The mouse cursor will assume this shape when it is over this window, unless an override cursor is set. See the list of predefined cursor objects for a range of useful shapes.
If no cursor has been set, or after a call to unsetCursor(), the parent window’s cursor is used.
By default, the cursor has the Qt::ArrowCursor shape.
Some underlying window implementations will reset the cursor if it leaves a window even if the mouse is grabbed. If you want to have a cursor set for all windows, even when outside the window, consider QGuiApplication::setOverrideCursor().
See also: GuiApplication::set_override_cursor
sourcepub fn unset_cursor(&self) -> &Self
pub fn unset_cursor(&self) -> &Self
sourcepub fn from_win_id(id: u64) -> Option<Window<'a>>
pub fn from_win_id(id: u64) -> Option<Window<'a>>
Creates a local representation of a window created by another process or by using native libraries below Qt.
Given the handle id to a native window, this method creates a QWindow object which can be used to represent the window when invoking methods like setParent() and setTransientParent().
This can be used, on platforms which support it, to embed a QWindow inside a native window, or to embed a native window inside a QWindow.
If foreign windows are not supported or embedding the native window failed in the platform plugin, this function returns 0.
Note: The resulting QWindow should not be used to manipulate the underlying native window (besides re-parenting), or to observe state changes of the native window. Any support for these kind of operations is incidental, highly platform dependent and untested.
See also: [set_parent()
]
See also: [set_transient_parent()
]
sourcepub fn request_activate(&self) -> &Self
pub fn request_activate(&self) -> &Self
Requests the window to be activated, i.e. receive keyboard focus.
See also: [is_active()
]
GuiApplication::focus_window
[WindowsWindowFunctions::set_window_activation_behavior
]
pub fn set_visible(&self, visible: bool) -> &Self
sourcepub fn show(&self) -> &Self
pub fn show(&self) -> &Self
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.
See also: [show_full_screen()
]
[show_maximized()
]
[show_normal()
]
[hide()
]
[StyleHints::show_is_full_screen
]
[flags()
]
Shows the window as minimized.
Equivalent to calling setWindowStates(Qt::WindowMinimized) and then setVisible(true).
See also: [set_window_states()
]
[set_visible()
]
Shows the window as maximized.
Equivalent to calling setWindowStates(Qt::WindowMaximized) and then setVisible(true).
See also: [set_window_states()
]
[set_visible()
]
Shows the window as fullscreen.
Equivalent to calling setWindowStates(Qt::WindowFullScreen) and then setVisible(true).
See also: [set_window_states()
]
[set_visible()
]
Shows the window as normal, i.e. neither maximized, minimized, nor fullscreen.
Equivalent to calling setWindowStates(Qt::WindowNoState) and then setVisible(true).
See also: [set_window_states()
]
[set_visible()
]
Override this to handle show events ( ev).
The function is called when the window has requested becoming visible.
If the window is successfully shown by the windowing system, this will be followed by a resize and an expose event.
sourcepub fn hide(&self) -> &Self
pub fn hide(&self) -> &Self
Hides the window.
Equivalent to calling setVisible(false).
See also: [show()
]
[set_visible()
]
Override this to handle hide events ( ev).
The function is called when the window has requested being hidden in the windowing system.
sourcepub fn show_minimized(&self) -> &Self
pub fn show_minimized(&self) -> &Self
Shows the window as minimized.
Equivalent to calling setWindowStates(Qt::WindowMinimized) and then setVisible(true).
See also: [set_window_states()
]
[set_visible()
]
sourcepub fn show_maximized(&self) -> &Self
pub fn show_maximized(&self) -> &Self
Shows the window as maximized.
Equivalent to calling setWindowStates(Qt::WindowMaximized) and then setVisible(true).
See also: [set_window_states()
]
[set_visible()
]
sourcepub fn show_full_screen(&self) -> &Self
pub fn show_full_screen(&self) -> &Self
Shows the window as fullscreen.
Equivalent to calling setWindowStates(Qt::WindowFullScreen) and then setVisible(true).
See also: [set_window_states()
]
[set_visible()
]
sourcepub fn show_normal(&self) -> &Self
pub fn show_normal(&self) -> &Self
Shows the window as normal, i.e. neither maximized, minimized, nor fullscreen.
Equivalent to calling setWindowStates(Qt::WindowNoState) and then setVisible(true).
See also: [set_window_states()
]
[set_visible()
]
sourcepub fn close(&self) -> bool
pub fn close(&self) -> bool
Close the window.
This closes the window, effectively calling destroy(), and potentially
quitting the application. Returns true
on success, false if it has a parent
window (in which case the top level window should be closed instead).
See also: [destroy()
]
GuiApplication::quit_on_last_window_closed
sourcepub fn raise(&self) -> &Self
pub fn raise(&self) -> &Self
Raise the window in the windowing system.
Requests that the window be raised to appear above other windows.
sourcepub fn lower(&self) -> &Self
pub fn lower(&self) -> &Self
Lower the window in the windowing system.
Requests that the window be lowered to appear below other windows.
pub fn set_title(&self, arg0: &str) -> &Self
pub fn set_x(&self, arg: i32) -> &Self
pub fn set_y(&self, arg: i32) -> &Self
pub fn set_width(&self, arg: i32) -> &Self
pub fn set_height(&self, arg: i32) -> &Self
pub fn set_minimum_width(&self, w: i32) -> &Self
pub fn set_minimum_height(&self, h: i32) -> &Self
pub fn set_maximum_width(&self, w: i32) -> &Self
pub fn set_maximum_height(&self, h: i32) -> &Self
sourcepub fn alert(&self, msec: i32) -> &Self
pub fn alert(&self, msec: i32) -> &Self
Causes an alert to be shown for msec miliseconds. If msec is 0
(the
default), then the alert is shown indefinitely until the window becomes
active again. This function has no effect on an active window.
In alert state, the window indicates that it demands attention, for example by flashing or bouncing the taskbar entry.
sourcepub fn request_update(&self) -> &Self
pub fn request_update(&self) -> &Self
Schedules a QEvent::UpdateRequest event to be delivered to this window.
The event is delivered in sync with the display vsync on platforms where this is possible. Otherwise, the event is delivered after a delay of 5 ms. The additional time is there to give the event loop a bit of idle time to gather system events, and can be overridden using the QT_QPA_UPDATE_IDLE_TIME environment variable.
When driving animations, this function should be called once after drawing has completed. Calling this function multiple times will result in a single event being delivered to the window.
Subclasses of QWindow should reimplement event(), intercept the event and call the application’s rendering code, then call the base class implementation.
Note: The subclass’ reimplementation of event() must invoke the base class implementation, unless it is absolutely sure that the event does not need to be handled by the base class. For example, the default implementation of this function relies on QEvent::Timer events. Filtering them away would therefore break the delivery of the update events.
sourcepub fn set_screen_changed_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &Screen<'_>) + 'a,
T: 'a,
pub fn set_screen_changed_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &Screen<'_>) + 'a,
T: 'a,
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.
pub fn set_screen_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&Screen<'_>) + 'a,
sourcepub fn set_window_title_changed_event_ud<F, T>(
&self,
data: &'a T,
func: F
) -> &Selfwhere
F: Fn(&T, &str) + 'a,
T: 'a,
pub fn set_window_title_changed_event_ud<F, T>(
&self,
data: &'a T,
func: F
) -> &Selfwhere
F: Fn(&T, &str) + 'a,
T: 'a,
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.
pub fn set_window_title_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&str) + 'a,
pub fn set_x_changed_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, i32) + 'a,
T: 'a,
pub fn set_x_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(i32) + 'a,
pub fn set_y_changed_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, i32) + 'a,
T: 'a,
pub fn set_y_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(i32) + 'a,
pub fn set_width_changed_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, i32) + 'a,
T: 'a,
pub fn set_width_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(i32) + 'a,
pub fn set_height_changed_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, i32) + 'a,
T: 'a,
pub fn set_height_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(i32) + 'a,
pub fn set_minimum_width_changed_event_ud<F, T>(
&self,
data: &'a T,
func: F
) -> &Selfwhere
F: Fn(&T, i32) + 'a,
T: 'a,
pub fn set_minimum_width_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(i32) + 'a,
pub fn set_minimum_height_changed_event_ud<F, T>(
&self,
data: &'a T,
func: F
) -> &Selfwhere
F: Fn(&T, i32) + 'a,
T: 'a,
pub fn set_minimum_height_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(i32) + 'a,
pub fn set_maximum_width_changed_event_ud<F, T>(
&self,
data: &'a T,
func: F
) -> &Selfwhere
F: Fn(&T, i32) + 'a,
T: 'a,
pub fn set_maximum_width_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(i32) + 'a,
pub fn set_maximum_height_changed_event_ud<F, T>(
&self,
data: &'a T,
func: F
) -> &Selfwhere
F: Fn(&T, i32) + 'a,
T: 'a,
pub fn set_maximum_height_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(i32) + 'a,
pub fn set_visible_changed_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, bool) + 'a,
T: 'a,
pub fn set_visible_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(bool) + 'a,
pub fn set_active_changed_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T) + 'a,
T: 'a,
pub fn set_active_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn() + 'a,
sourcepub fn set_focus_object_changed_event_ud<F, T>(
&self,
data: &'a T,
func: F
) -> &Selfwhere
F: Fn(&T, &Object<'_>) + 'a,
T: 'a,
pub fn set_focus_object_changed_event_ud<F, T>(
&self,
data: &'a T,
func: F
) -> &Selfwhere
F: Fn(&T, &Object<'_>) + 'a,
T: 'a,
This signal is emitted when the final receiver of events tied to focus is changed to object.
See also: [focus_object()
]
pub fn set_focus_object_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&Object<'_>) + 'a,
pub fn set_opacity_changed_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, f32) + 'a,
T: 'a,
pub fn set_opacity_changed_event<F>(&self, func: F) -> &Selfwhere
F: Fn(f32) + 'a,
sourcepub fn set_expose_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &ExposeEvent<'_>) + 'a,
T: 'a,
pub fn set_expose_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &ExposeEvent<'_>) + 'a,
T: 'a,
The expose event ( ev) is sent by the window system whenever the window’s exposure on screen changes.
The application can start rendering into the window with QBackingStore and QOpenGLContext as soon as it gets an exposeEvent() such that isExposed() is true.
If the window is moved off screen, is made totally obscured by another window, iconified or similar, this function might be called and the value of isExposed() might change to false. When this happens, an application should stop its rendering as it is no longer visible to the user.
A resize event will always be sent before the expose event the first time a window is shown.
See also: [is_exposed()
]
pub fn set_expose_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&ExposeEvent<'_>) + 'a,
sourcepub fn set_resize_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &ResizeEvent<'_>) + 'a,
T: 'a,
pub fn set_resize_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &ResizeEvent<'_>) + 'a,
T: 'a,
Override this to handle resize events ( ev).
The resize event is called whenever the window is resized in the windowing system, either directly through the windowing system acknowledging a setGeometry() or resize() request, or indirectly through the user resizing the window manually.
pub fn set_resize_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&ResizeEvent<'_>) + 'a,
sourcepub fn set_move_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &MoveEvent<'_>) + 'a,
T: 'a,
pub fn set_move_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &MoveEvent<'_>) + 'a,
T: 'a,
Override this to handle window move events ( ev).
pub fn set_move_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&MoveEvent<'_>) + 'a,
sourcepub fn set_focus_in_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &FocusEvent<'_>) + 'a,
T: 'a,
pub fn set_focus_in_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &FocusEvent<'_>) + 'a,
T: 'a,
Override this to handle focus in events ( ev).
Focus in events are sent when the window receives keyboard focus.
See also: [focus_out_event()
]
pub fn set_focus_in_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&FocusEvent<'_>) + 'a,
sourcepub fn set_focus_out_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &FocusEvent<'_>) + 'a,
T: 'a,
pub fn set_focus_out_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &FocusEvent<'_>) + 'a,
T: 'a,
Override this to handle focus out events ( ev).
Focus out events are sent when the window loses keyboard focus.
See also: [focus_in_event()
]
pub fn set_focus_out_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&FocusEvent<'_>) + 'a,
sourcepub fn set_show_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &ShowEvent<'_>) + 'a,
T: 'a,
pub fn set_show_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &ShowEvent<'_>) + 'a,
T: 'a,
Override this to handle show events ( ev).
The function is called when the window has requested becoming visible.
If the window is successfully shown by the windowing system, this will be followed by a resize and an expose event.
pub fn set_show_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&ShowEvent<'_>) + 'a,
sourcepub fn set_hide_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &HideEvent<'_>) + 'a,
T: 'a,
pub fn set_hide_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &HideEvent<'_>) + 'a,
T: 'a,
Override this to handle hide events ( ev).
The function is called when the window has requested being hidden in the windowing system.
pub fn set_hide_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&HideEvent<'_>) + 'a,
sourcepub fn set_key_press_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &KeyEvent<'_>) + 'a,
T: 'a,
pub fn set_key_press_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &KeyEvent<'_>) + 'a,
T: 'a,
Override this to handle key press events ( ev).
See also: [key_release_event()
]
pub fn set_key_press_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&KeyEvent<'_>) + 'a,
sourcepub fn set_key_release_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &KeyEvent<'_>) + 'a,
T: 'a,
pub fn set_key_release_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &KeyEvent<'_>) + 'a,
T: 'a,
Override this to handle key release events ( ev).
See also: [key_press_event()
]
pub fn set_key_release_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&KeyEvent<'_>) + 'a,
sourcepub fn set_mouse_press_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &MouseEvent<'_>) + 'a,
T: 'a,
pub fn set_mouse_press_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &MouseEvent<'_>) + 'a,
T: 'a,
Override this to handle mouse press events ( ev).
See also: [mouse_release_event()
]
pub fn set_mouse_press_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&MouseEvent<'_>) + 'a,
sourcepub fn set_mouse_release_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &MouseEvent<'_>) + 'a,
T: 'a,
pub fn set_mouse_release_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &MouseEvent<'_>) + 'a,
T: 'a,
Override this to handle mouse release events ( ev).
See also: [mouse_press_event()
]
pub fn set_mouse_release_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&MouseEvent<'_>) + 'a,
sourcepub fn set_mouse_double_click_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &MouseEvent<'_>) + 'a,
T: 'a,
pub fn set_mouse_double_click_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &MouseEvent<'_>) + 'a,
T: 'a,
Override this to handle mouse double click events ( ev).
See also: [mouse_press_event()
]
[StyleHints::mouse_double_click_interval
]
pub fn set_mouse_double_click_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&MouseEvent<'_>) + 'a,
sourcepub fn set_mouse_move_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &MouseEvent<'_>) + 'a,
T: 'a,
pub fn set_mouse_move_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &MouseEvent<'_>) + 'a,
T: 'a,
Override this to handle mouse move events ( ev).
pub fn set_mouse_move_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&MouseEvent<'_>) + 'a,
sourcepub fn set_wheel_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &WheelEvent<'_>) + 'a,
T: 'a,
pub fn set_wheel_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &WheelEvent<'_>) + 'a,
T: 'a,
Override this to handle mouse wheel or other wheel events ( ev).
pub fn set_wheel_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&WheelEvent<'_>) + 'a,
sourcepub fn set_touch_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &TouchEvent<'_>) + 'a,
T: 'a,
pub fn set_touch_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &TouchEvent<'_>) + 'a,
T: 'a,
Override this to handle touch events ( ev).
pub fn set_touch_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&TouchEvent<'_>) + 'a,
sourcepub fn set_tablet_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &TabletEvent<'_>) + 'a,
T: 'a,
pub fn set_tablet_event_ud<F, T>(&self, data: &'a T, func: F) -> &Selfwhere
F: Fn(&T, &TabletEvent<'_>) + 'a,
T: 'a,
Override this to handle tablet press, move, and release events ( ev).
Proximity enter and leave events are not sent to windows, they are delivered to the application instance.