add book
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(2-SettingsAutomatic VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick QuickControls2)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_executable(app2-SettingsAutomatic
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app2-SettingsAutomatic
|
||||
URI 2-SettingsAutomatic
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app2-SettingsAutomatic PROPERTIES
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
MACOSX_BUNDLE TRUE
|
||||
WIN32_EXECUTABLE TRUE
|
||||
)
|
||||
|
||||
target_link_libraries(app2-SettingsAutomatic
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app2-SettingsAutomatic
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
54
Qt6QMLBeginnersCode/13-Storage/2-SettingsAutomatic/Main.qml
Normal file
54
Qt6QMLBeginnersCode/13-Storage/2-SettingsAutomatic/Main.qml
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Dialogs
|
||||
import QtCore
|
||||
|
||||
Window {
|
||||
id: rootId
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("SettingsDemo1")
|
||||
|
||||
Rectangle {
|
||||
id: rectId
|
||||
anchors.fill: parent
|
||||
color: "red"
|
||||
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
colorDialogId.open()
|
||||
}
|
||||
|
||||
ColorDialog {
|
||||
id: colorDialogId
|
||||
title: "Please choose a color"
|
||||
onAccepted: {
|
||||
console.log("The new color is: "+ selectedColor)
|
||||
rectId.color = selectedColor
|
||||
}
|
||||
onRejected: {
|
||||
console.log("Canceled")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Settings{
|
||||
category: "window"
|
||||
property alias x: rootId.x
|
||||
property alias y: rootId.y
|
||||
property alias width: rootId.width
|
||||
property alias height: rootId.height
|
||||
}
|
||||
|
||||
Settings{
|
||||
category: "colors"
|
||||
property alias rectColor: rectId.color
|
||||
}
|
||||
|
||||
}
|
||||
28
Qt6QMLBeginnersCode/13-Storage/2-SettingsAutomatic/main.cpp
Normal file
28
Qt6QMLBeginnersCode/13-Storage/2-SettingsAutomatic/main.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQuickStyle>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQuickStyle::setStyle("Basic");
|
||||
|
||||
//App Information
|
||||
app.setOrganizationName("LearnQt");
|
||||
app.setOrganizationDomain("learnqt.guide");
|
||||
app.setApplicationName("SettingsDemo");
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("2-SettingsAutomatic", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user