TopLevelWindow Object

Information about and manipulation of toplevel windows. In order to use this ToplevelWindow object, the Squish toplevelwindow library has to be included in the script file.

source(findFile("scripts", "javascript/toplevelwindow.js"));

    // ...

    var win = ToplevelWindow.focused();
    var geom = win.geometry;
    test.log("Focused window is " + geom.width + " by " + geom.height);
use strict;
use utf8;
use warnings;

use Squish::ToplevelWindow;

    # ...

    my $win = Squish::ToplevelWindow->focused();
    my $geom = $win->geometry;
    test::log("Focused window is " . $geom->width . " by " . $geom->height);
# -*- coding: utf-8 -*-
from toplevelwindow import *

    # ...

    win = ToplevelWindow.focused()
    geom = win.geometry
    test.log("Focused window is " + str(geom.width) + " by " + str(geom.height))
# encoding: UTF-8
require 'squish'
require 'squish/toplevelwindow'

    # ...

    win = ToplevelWindow::focused()
    geom = win.geometry
    test.log("Focused window is " + geom.width + " by " + geom.height)
package require squish::toplevelwindow

    # ...

    set win [Squish::ToplevelWindow focused]
    set geom [$win geometry]
    test log "Focused window is [property get $geom width] by [property get $geom height]"

ToplevelWindow.byName(objectname, timeout)

ToplevelWindow.byObject(object)

These methods return a ToplevelWindow object for the given objectname or object. The first is a convenience method for calling the second, with the result of Object waitForObject(objectOrName). These methods accept different argument types depending on the toolkit, and should work with most top-level windows such as Dialogs, Main Windows, and Browser Tabs.

tlw = ToplevelWindow.byName({'type': 'BrowserTab'})
#  ... is equivalent to ...
tlw = ToplevelWindow.byObject(activeBrowserTab())

ToplevelWindow.focused()

This method returns a ToplevelWindow object for the window having the keyboard focus. When no window found having the keyboard focus, an exception is raised.

Note: To obtain an instance of TopLevelWindow from Squish for Web, use ToplevelWindow.byObject(activeBrowserTab()). The focused() method is not supported.

geometry

Read-only property of a ToplevelWindow object that returns a ScreenRectangle containing the dimensions of the referenced window.

nativeObject

Read-only property of a ToplevelWindow object that returns the object for which this ToplevelWindow object was created.

close()

This method closes the window referenced by this ToplevelWindow object.

maximize()

This method maximizes the window referenced by this ToplevelWindow object.

minimize()

This method minimizes the window referenced by this ToplevelWindow object.

moveTo(x, y)

This method moves the client-area (excluding window borders) upper left corner of the window referenced by this ToplevelWindow object, to the given global position.

resizeTo(width, height)

This method resizes the client-area (excluding window borders) of the window referenced by this ToplevelWindow object, to the given width and height.

restore()

This method restores the window referenced by this ToplevelWindow object from fullscreen.

setFocus()

This method sets the keyboard input focus to the window referenced by this ToplevelWindow object.

Note: On Windows, the focus theft protection feature prevents certain APIs from changing the focus from the active window. Therefore, setFocus may have no effect on Windows systems.

Note: This function is not supported for Squish for Web. It will generate an error when being used.

setForeground()

This raises the window referenced by this ToplevelWindow object.

Note: On Windows, the foreground lock protection feature prevents certain APIs from changing the foreground window. Therefore, setForeground may have no effect on Windows systems.

Note: This function is not supported for Squish for Web. It will generate an error when being used.

setFullscreen()

This changes the window referenced by this ToplevelWindow object to fullscreen, i.e., covering the whole screen without window borders. Use restore() to undo this operation.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Search Results