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(15-Switch 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(app15-Switch
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app15-Switch
|
||||
URI 15-Switch
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app15-Switch 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(app15-Switch
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app15-Switch
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
40
Qt6QMLBeginnersCode/8-QtQuickControls/15-Switch/Main.qml
Normal file
40
Qt6QMLBeginnersCode/8-QtQuickControls/15-Switch/Main.qml
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("Switch")
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 20
|
||||
|
||||
Switch{
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "WiFi"
|
||||
checked: true
|
||||
onCheckedChanged: {
|
||||
if(checked)
|
||||
{
|
||||
console.log("WiFi switch is turned ON")
|
||||
}else{
|
||||
console.log("WiFi switch is turned OFF")
|
||||
}
|
||||
}
|
||||
}
|
||||
Switch{
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Bluetooth"
|
||||
}
|
||||
Switch{
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "NFC"
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Qt6QMLBeginnersCode/8-QtQuickControls/15-Switch/main.cpp
Normal file
21
Qt6QMLBeginnersCode/8-QtQuickControls/15-Switch/main.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQuickStyle>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QQuickStyle::setStyle("Material");
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("15-Switch", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user