π± Application Window
ApplicationWindow is a Window which makes it convenient to add a menu bar, header and footer item to the window.
You can declare ApplicationWindow as the root item of your application, and run it by using QQmlApplicationEngine. In this way you can control the windowβs properties, appearance and layout from QML.
WindowLayoutSave
WindowLayoutSave
is an easy to use Item that will save and restore its target Window
properties: x
, y
, width
, height
. It will also respect minimumWidth
and minimumHeight
.
import Qaterial as Qaterial
Qaterial.ApplicationWindow
{
id: window
width: 500
height: 300
minimumWidth: 100
minimumHeight: 100
// Save and restore x, y, width, height
Qaterial.WindowLayoutSave { }
}
Example can be found in examples/WindowSaveLayout.qml
.
Properties
target
The target of the WindowLayoutSave
is defaulted to the attached property Window.window
. This can be overwritten if wanted. The target is expected to have x
, y
, width
, height
, minimumWidth
, minimumHeight
properties.
enable
Enable of disable the WindowLayoutSave restoring behavior. By default itβs true.
visible
When using a WindowSaveLayout
, the ApplicationWindow
βs visible
property should be left at false. When constructing, the WindowLayoutSave
will change ApplicationWindow
visible
to true.
If you need to manage the visible property of the Window by yourself, then set visible of WindowLayoutSave
to false.
import Qaterial as Qaterial
Qaterial.ApplicationWindow
{
Qaterial.WindowLayoutSave { visible: false }
Component.onCompleted: () => visible = true
}
name
Window name to support multiple Window in the same application. This is used to create a custom Settings
category for each window. If left empty, it will only be possible to support one Window in the application.
This property can also be used to remember multiple location, for user profile for example.
Note
WindowLayoutSave
is using Settings. It require you to register your application with identifier.
Application specific settings are identified by providing application name, organization and domain, or by specifying fileName.
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
app.setOrganizationName("Some Company");
app.setOrganizationDomain("somecompany.com");
app.setApplicationName("Amazing Application");
QQmlApplicationEngine engine("main.qml");
return app.exec();
}