IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Qt Quick Examples - Window and Screen

This example demonstrates the Window and Screen types in QML.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

Qt Quick Examples - Window and Screen▲

Image non disponible

Window and Screen shows how to:

  • create a window in QML

  • control its https://

  • present a splash screen during application startup

  • access the properties of the https://

It also demonstrates how to package QML into https:// and provide an icon to create a standalone QML desktop application.

Running the Example▲

To run the example from https://, open the Welcome mode and select the example from Examples. For more information, visit https://.

Window Implementation▲

A splash screen can be created with the https:// flag, and should be https:// to prevent interaction with the main window. If the splash window is also transparent, and showing a partially transparent image, then it will look like a shaped window.

 
Sélectionnez
Window {
    id: splash
    color: "transparent"
    title: "Splash Window"
    modality: Qt.ApplicationModal
    flags: Qt.SplashScreen
    property int timeoutInterval: 2000
    signal timeout

In this example a https:// will automatically dismiss the splash screen, but in a real application you might want to connect to a signal from the application logic to hide the splash when initialization is complete.

 
Sélectionnez
Timer {
    interval: splash.timeoutInterval; running: true; repeat: false
    onTriggered: {
        splash.visible = false
        splash.timeout()
    }
}

The main window in this example is the control window, with some buttons and checkboxes to control and provide feedback on the state of a secondary window. Each checkbox has a binding to the property whose state it is displaying, and also an onClicked handler to change the state. This is the typical pattern to create a two-way binding while avoiding binding loops.

 
Sélectionnez
CheckBox {
    text: "Windowed"
    height: showButton.height
    width: col.cellWidth
    Binding on checked { value: root.testWindow.visibility === Window.Windowed }
    onClicked: root.testWindow.visibility = Window.Windowed
}

https:// has several properties which are generally useful to applications which need to rotate some content when the screen orientation changes, to position windows on the screen or to convert real units to logical pixel units. CurrentScreen.qml (which is displayed inline in window.qml, or can be run by itself with the qml tool) simply displays the property values, while the splash screen uses them to center the window on the screen.

 
Sélectionnez
    x: (Screen.width - splashImage.width) / 2
    y: (Screen.height - splashImage.height) / 2

If a https:// is nested inside an https:// or another Window, the inner window becomes transient for the outer one (see https:// for more explanation). But if you want to create multiple top-level windows as unrelated peers, you can create them inside a non-visual https:// root item, as this example does.

Example project▲

https://

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.