add book
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(10-SwipeViewPageIndicator VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_executable(app10-SwipeViewPageIndicator
|
||||
main.cpp resource.qrc
|
||||
)
|
||||
|
||||
qt_add_qml_module(app10-SwipeViewPageIndicator
|
||||
URI 10-SwipeViewPageIndicator
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app10-SwipeViewPageIndicator 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(app10-SwipeViewPageIndicator
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
install(TARGETS app10-SwipeViewPageIndicator
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("PageIndicator and SwipeView")
|
||||
|
||||
SwipeView{
|
||||
id: swipeViewId
|
||||
anchors.fill: parent
|
||||
currentIndex: pageIndicatorId.currentIndex
|
||||
anchors.bottomMargin: 20
|
||||
|
||||
Image {
|
||||
id: image1
|
||||
fillMode: Image.PreserveAspectFit
|
||||
//source: "https://www.learnqt.guide/images/qt_quick_fundamentals.png"
|
||||
source:"qrc:/images/1.png"
|
||||
}
|
||||
Image {
|
||||
id: image2
|
||||
fillMode: Image.PreserveAspectFit
|
||||
//source: "https://www.learnqt.guide/images/qt_quick_intermediate.png"
|
||||
source: "qrc:/images/2.png"
|
||||
}
|
||||
Image {
|
||||
id: image3
|
||||
fillMode: Image.PreserveAspectFit
|
||||
//source: "https://www.learnqt.guide/images/qt_quick_advanced.png"
|
||||
source: "qrc:/images/3.png"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PageIndicator{
|
||||
id: pageIndicatorId
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
//Page indicator specific properties
|
||||
currentIndex: swipeViewId.currentIndex
|
||||
interactive: true
|
||||
count: swipeViewId.count
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 497 KiB |
|
After Width: | Height: | Size: 513 KiB |
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("10-SwipeViewPageIndicator", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>images/1.png</file>
|
||||
<file>images/2.png</file>
|
||||
<file>images/3.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(11-ProgressBar 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(app11-ProgressBar
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app11-ProgressBar
|
||||
URI 11-ProgressBar
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app11-ProgressBar 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(app11-ProgressBar
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app11-ProgressBar
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("ProgressBar")
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 20
|
||||
|
||||
Button {
|
||||
text: "Start"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
onClicked: {
|
||||
progressBarId.value = 78
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Dial {
|
||||
id: dialId
|
||||
from : 1
|
||||
to: 100
|
||||
value: 40
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
onValueChanged: {
|
||||
progressBarId.value = value
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ProgressBar {
|
||||
id: progressBarId
|
||||
from: 1
|
||||
to: 100
|
||||
value: 40
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
id: progressBarId1
|
||||
indeterminate: true
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// 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("11-ProgressBar", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(12-RangeSlider 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(app12-RangeSlider
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app12-RangeSlider
|
||||
URI 12-RangeSlider
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app12-RangeSlider 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(app12-RangeSlider
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app12-RangeSlider
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("RangeSlider")
|
||||
|
||||
Row {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
||||
RangeSlider{
|
||||
//orientation: Qt.Vertical
|
||||
from: 1
|
||||
to: 100
|
||||
first.value: 25
|
||||
second.value: 75
|
||||
|
||||
first.onValueChanged: {
|
||||
console.log("First value changed to: "+ first.value)
|
||||
}
|
||||
second.onValueChanged: {
|
||||
console.log("Second value changed to: "+ second.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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("Default");
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("12-RangeSlider", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(13-FlickableScrollbar 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(app13-FlickableScrollbar
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app13-FlickableScrollbar
|
||||
URI 13-FlickableScrollbar
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app13-FlickableScrollbar 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(app13-FlickableScrollbar
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app13-FlickableScrollbar
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
@@ -0,0 +1,125 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("Flickable and Scrollbar")
|
||||
|
||||
Flickable{
|
||||
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
contentHeight: mColumnId.implicitHeight
|
||||
|
||||
|
||||
Column{
|
||||
id: mColumnId
|
||||
anchors.fill: parent
|
||||
|
||||
Rectangle {
|
||||
color: "red"
|
||||
width: parent.width
|
||||
height: 200
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Element 1"
|
||||
font.pointSize: 30
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Rectangle {
|
||||
color: "blue"
|
||||
width: parent.width
|
||||
height: 200
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Element 2"
|
||||
font.pointSize: 30
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: "yellow"
|
||||
width: parent.width
|
||||
height: 200
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Element 3"
|
||||
font.pointSize: 30
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: "magenta"
|
||||
width: parent.width
|
||||
height: 200
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Element 4"
|
||||
font.pointSize: 30
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
color: "yellowgreen"
|
||||
width: parent.width
|
||||
height: 200
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Element 5"
|
||||
font.pointSize: 30
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
/*
|
||||
Rectangle {
|
||||
color: "red"
|
||||
width: parent.width
|
||||
height: 200
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Element 6"
|
||||
font.pointSize: 30
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
color: "beige"
|
||||
width: parent.width
|
||||
height: 200
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Element 7"
|
||||
font.pointSize: 30
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
color: "royalblue"
|
||||
width: parent.width
|
||||
height: 200
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Element 8"
|
||||
font.pointSize: 30
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ScrollBar.vertical: ScrollBar{}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// 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("Universal");
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("13-FlickableScrollbar", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(14-Slider VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_executable(app14-Slider
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app14-Slider
|
||||
URI 14-Slider
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app14-Slider 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(app14-Slider
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
install(TARGETS app14-Slider
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
38
Qt6QMLBeginnersCode/8-QtQuickControls/14-Slider/Main.qml
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("Slider")
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 20
|
||||
|
||||
Slider {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width
|
||||
from: 1
|
||||
to: 100
|
||||
value: 40
|
||||
onValueChanged: {
|
||||
progressBarId.value = value
|
||||
}
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width
|
||||
id: progressBarId
|
||||
from : 1
|
||||
to: 100
|
||||
value: 40
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Qt6QMLBeginnersCode/8-QtQuickControls/14-Slider/main.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("14-Slider", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -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
@@ -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
@@ -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();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(16-PageTabBar VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_executable(app16-PageTabBar
|
||||
main.cpp resource.qrc
|
||||
)
|
||||
|
||||
qt_add_qml_module(app16-PageTabBar
|
||||
URI 16-PageTabBar
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app16-PageTabBar 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(app16-PageTabBar
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
install(TARGETS app16-PageTabBar
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
64
Qt6QMLBeginnersCode/8-QtQuickControls/16-PageTabBar/Main.qml
Normal file
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 480
|
||||
height: 640
|
||||
title: qsTr("Page and TabBar")
|
||||
|
||||
Page {
|
||||
id: pageId
|
||||
anchors.fill: parent
|
||||
|
||||
header: Rectangle{
|
||||
width: parent.width
|
||||
height: 50
|
||||
color: "yellowgreen"
|
||||
Text{
|
||||
text: "Some header text"
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
||||
SwipeView{
|
||||
id: swipeViewId
|
||||
anchors.fill: parent
|
||||
currentIndex: tabBarId.currentIndex
|
||||
|
||||
Image{
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: "qrc:/images/1.png"
|
||||
}
|
||||
|
||||
Image{
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: "qrc:/images/2.png"
|
||||
}
|
||||
Image{
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: "qrc:/images/3.png"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
footer: TabBar{
|
||||
id: tabBarId
|
||||
currentIndex: swipeViewId.currentIndex
|
||||
|
||||
TabButton{
|
||||
text: "First"
|
||||
}
|
||||
TabButton{
|
||||
text: "Second"
|
||||
}
|
||||
TabButton{
|
||||
text: "Third"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Qt6QMLBeginnersCode/8-QtQuickControls/16-PageTabBar/images/1.png
Normal file
|
After Width: | Height: | Size: 118 KiB |
BIN
Qt6QMLBeginnersCode/8-QtQuickControls/16-PageTabBar/images/2.png
Normal file
|
After Width: | Height: | Size: 497 KiB |
BIN
Qt6QMLBeginnersCode/8-QtQuickControls/16-PageTabBar/images/3.png
Normal file
|
After Width: | Height: | Size: 513 KiB |
20
Qt6QMLBeginnersCode/8-QtQuickControls/16-PageTabBar/main.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("16-PageTabBar", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>images/1.png</file>
|
||||
<file>images/2.png</file>
|
||||
<file>images/3.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(17-TextAreaScrollView VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_executable(app17-TextAreaScrollView
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app17-TextAreaScrollView
|
||||
URI 17-TextAreaScrollView
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app17-TextAreaScrollView 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(app17-TextAreaScrollView
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
install(TARGETS app17-TextAreaScrollView
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("TextArea")
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
wrapMode: Label.Wrap
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
text: "TextArea is a multi-line text editor."
|
||||
}
|
||||
|
||||
|
||||
ScrollView{
|
||||
id: scrollView
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width
|
||||
height: 150
|
||||
TextArea {
|
||||
id: textAreaId
|
||||
font.pointSize: 15
|
||||
wrapMode: TextArea.WordWrap
|
||||
placeholderText: "Type in your query"
|
||||
text: "TextArea is a QML element where you can type in multiple lines of text and more and more and more At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat TextArea is a QML element where you can type in multiple lines of text and more and more and more At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat TextArea is a QML element where you can type in multiple lines of text and more and more and more At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat end"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Button{
|
||||
text: "Submit"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
onClicked: {
|
||||
console.log("The text inside the TextArea is: "+ textAreaId.text)
|
||||
textAreaId.text = textAreaId.text + "sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facili1111"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("17-TextAreaScrollView", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(18-TextFieldLabel VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_executable(app18-TextFieldLabel
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app18-TextFieldLabel
|
||||
URI 18-TextFieldLabel
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app18-TextFieldLabel 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(app18-TextFieldLabel
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
install(TARGETS app18-TextFieldLabel
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("TextField")
|
||||
|
||||
Column {
|
||||
spacing: 20
|
||||
anchors.centerIn: parent
|
||||
|
||||
Row {
|
||||
spacing: 30
|
||||
width: 300
|
||||
|
||||
Label {
|
||||
width: 100
|
||||
height: 50
|
||||
wrapMode: Label.Wrap
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
text: "First Name : "
|
||||
}
|
||||
|
||||
TextField {
|
||||
id : textFieldId
|
||||
width: 200
|
||||
height: 50
|
||||
placeholderText: "Type your First Name"
|
||||
onEditingFinished: {
|
||||
console.log("Text Edit Finished : "+ text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
text : "Click"
|
||||
onClicked: {
|
||||
console.log("Text is :"+ textFieldId.text)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("18-TextFieldLabel", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(19-SplitView VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_executable(app19-SplitView
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app19-SplitView
|
||||
URI 19-SplitView
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app19-SplitView 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(app19-SplitView
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
install(TARGETS app19-SplitView
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
43
Qt6QMLBeginnersCode/8-QtQuickControls/19-SplitView/Main.qml
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("SplitView")
|
||||
|
||||
|
||||
SplitView {
|
||||
anchors.fill: parent
|
||||
orientation: Qt.Horizontal
|
||||
|
||||
Rectangle {
|
||||
SplitView.preferredWidth: 150
|
||||
SplitView.minimumWidth: 100
|
||||
color: "lightblue"
|
||||
Text {
|
||||
text: "View 1"
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
SplitView.preferredWidth: 100
|
||||
color: "lightgray"
|
||||
Text {
|
||||
text: "View 2"
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
SplitView.preferredWidth: 150
|
||||
color: "lightgreen"
|
||||
Text {
|
||||
text: "View 3"
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Qt6QMLBeginnersCode/8-QtQuickControls/19-SplitView/main.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("19-SplitView", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(2-Button 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-Button
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app2-Button
|
||||
URI 2-Button
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app2-Button 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-Button
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app2-Button
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
35
Qt6QMLBeginnersCode/8-QtQuickControls/2-Button/Main.qml
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("Button")
|
||||
|
||||
ColumnLayout {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
Button {
|
||||
id: button1
|
||||
text: "Button1"
|
||||
Layout.fillWidth: true
|
||||
onClicked: {
|
||||
console.log("Clicked on button1")
|
||||
}
|
||||
}
|
||||
Button{
|
||||
id: button2
|
||||
text : "Button2"
|
||||
Layout.fillWidth: true
|
||||
onClicked: {
|
||||
console.log("Clicked on button2")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Qt6QMLBeginnersCode/8-QtQuickControls/2-Button/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);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
|
||||
//Load our style
|
||||
QQuickStyle::setStyle("Material");
|
||||
//QQuickStyle::setStyle("Universal");
|
||||
//QQuickStyle::setStyle("Fusion");
|
||||
//QQuickStyle::setStyle("Imagine");
|
||||
//QQuickStyle::setStyle("Default");
|
||||
|
||||
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("2-Button", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(20-Drawer VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTORCC ON)
|
||||
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(app20-Drawer
|
||||
main.cpp resource.qrc
|
||||
)
|
||||
|
||||
qt_add_qml_module(app20-Drawer
|
||||
URI 20-Drawer
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app20-Drawer 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(app20-Drawer
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app20-Drawer
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
122
Qt6QMLBeginnersCode/8-QtQuickControls/20-Drawer/Main.qml
Normal file
@@ -0,0 +1,122 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
ApplicationWindow {
|
||||
id : rootId
|
||||
visible: true
|
||||
width: 360
|
||||
height: 520
|
||||
title: qsTr("Drawer")
|
||||
|
||||
header: ToolBar{
|
||||
height: 50
|
||||
background: Rectangle{
|
||||
color: "mintcream"
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: 20
|
||||
anchors.fill: parent
|
||||
|
||||
ToolButton{
|
||||
background: Rectangle{
|
||||
color: "mintcream"
|
||||
}
|
||||
|
||||
icon.source: "qrc:/images/drawer.png"
|
||||
|
||||
onClicked: {
|
||||
console.log("Toolbutton clicked")
|
||||
//Open Drawer
|
||||
drawerId.open()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Label {
|
||||
id: titleLabel
|
||||
text: "Drawer App"
|
||||
font.pixelSize: 20
|
||||
elide: Label.ElideRight
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
Layout.fillWidth: true
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Drawer {
|
||||
id: drawerId
|
||||
width: Math.min(rootId.width,rootId.height) * (2/3)
|
||||
height: rootId.height
|
||||
interactive: true
|
||||
|
||||
ColumnLayout{
|
||||
spacing: 0
|
||||
width: parent.width
|
||||
|
||||
Button{
|
||||
width: parent.width
|
||||
height: 50
|
||||
text : "Item1"
|
||||
font.pointSize: 20
|
||||
background: Rectangle{
|
||||
color: "beige"
|
||||
}
|
||||
Layout.fillWidth: true
|
||||
|
||||
onClicked: {
|
||||
console.log("Clicked on item1 ")
|
||||
contentRectId.color = "red"
|
||||
drawerId.close()
|
||||
}
|
||||
}
|
||||
Button{
|
||||
width: parent.width
|
||||
height: 50
|
||||
text : "Item2"
|
||||
font.pointSize: 20
|
||||
background: Rectangle{
|
||||
color: "yellowgreen"
|
||||
}
|
||||
Layout.fillWidth: true
|
||||
|
||||
onClicked: {
|
||||
console.log("Clicked on item2 ")
|
||||
contentRectId.color = "green"
|
||||
drawerId.close()
|
||||
}
|
||||
}
|
||||
Button{
|
||||
width: parent.width
|
||||
height: 50
|
||||
text : "Item3"
|
||||
font.pointSize: 20
|
||||
background: Rectangle{
|
||||
color: "dodgerblue"
|
||||
}
|
||||
Layout.fillWidth: true
|
||||
|
||||
onClicked: {
|
||||
console.log("Clicked on item3 ")
|
||||
contentRectId.color = "blue"
|
||||
drawerId.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
id : contentRectId
|
||||
anchors.fill: parent
|
||||
color: "gray"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 123 B |
22
Qt6QMLBeginnersCode/8-QtQuickControls/20-Drawer/main.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// 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("Fusion");
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("20-Drawer", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>images/drawer.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(21-ApplicationWindow VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_executable(app21-ApplicationWindow
|
||||
main.cpp resource.qrc
|
||||
)
|
||||
|
||||
qt_add_qml_module(app21-ApplicationWindow
|
||||
URI 21-ApplicationWindow
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml Page1.qml Page2.qml Page3.qml
|
||||
)
|
||||
|
||||
set_target_properties(app21-ApplicationWindow 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(app21-ApplicationWindow
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
install(TARGETS app21-ApplicationWindow
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
@@ -0,0 +1,131 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
ApplicationWindow {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("ApplicationWindow Demo")
|
||||
|
||||
menuBar: MenuBar {
|
||||
Menu {
|
||||
title: qsTr("&File")
|
||||
Action {
|
||||
id: newActionId
|
||||
text: qsTr("&New")
|
||||
icon.source: "qrc:/images/newFileIcon.png"
|
||||
onTriggered: {
|
||||
console.log("Clicked on new")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Action {
|
||||
id: openActionId
|
||||
text: qsTr("&Open...")
|
||||
icon.source: "qrc:/images/openIcon.png"
|
||||
|
||||
}
|
||||
Action {
|
||||
id: saveActionId
|
||||
text: qsTr("&Save")
|
||||
icon.source: "qrc:/images/saveIcon.png"
|
||||
}
|
||||
Action {
|
||||
id: saveAsActionId
|
||||
text: qsTr("Save &As...")
|
||||
icon.source: "qrc:/images/saveAsIcon.png"
|
||||
}
|
||||
|
||||
MenuSeparator{}
|
||||
Action {
|
||||
id: quitActionId
|
||||
text: qsTr("Quit")
|
||||
icon.source: "qrc:/images/quitIcon.png"
|
||||
onTriggered: Qt.quit()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
title: qsTr("&Edit")
|
||||
Action {id: cutMenuId; icon.source: "qrc:/images/cutIcon.png"; text: qsTr("Cut") }
|
||||
Action {
|
||||
text: qsTr("Copy")
|
||||
icon.source: "qrc:/images/copyIcon.png"
|
||||
}
|
||||
Action { text: qsTr("Paste") ; icon.source: "qrc:/images/pasteIcon.png"}
|
||||
MenuSeparator { }
|
||||
Action { text: qsTr("Undo"); icon.source: "qrc:/images/undoIcon.png" }
|
||||
Action { text: qsTr("Redo") ; icon.source: "qrc:/images/redoIcon.png"}
|
||||
}
|
||||
Menu {
|
||||
id: helpMenu
|
||||
title: qsTr("&Help")
|
||||
Action {
|
||||
text: qsTr("&About")
|
||||
icon.source: "qrc:/images/info.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header: ToolBar {
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
ToolButton{
|
||||
action: newActionId
|
||||
}
|
||||
ToolButton{
|
||||
action: saveActionId
|
||||
}
|
||||
ToolButton{
|
||||
action: saveAsActionId
|
||||
}
|
||||
ToolButton{
|
||||
action: quitActionId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
footer: TabBar {
|
||||
id: mTabBar
|
||||
width: parent.width
|
||||
|
||||
TabButton {
|
||||
text : qsTr("Page1")
|
||||
onClicked: {
|
||||
mStackId.pop()
|
||||
mStackId.push("Page1.qml")
|
||||
console.log("Number of items : " + mStackId.depth)
|
||||
}
|
||||
}
|
||||
TabButton {
|
||||
text : qsTr("Page2")
|
||||
onClicked: {
|
||||
mStackId.pop()
|
||||
mStackId.push("Page2.qml")
|
||||
console.log("Number of items : " + mStackId.depth)
|
||||
}
|
||||
}
|
||||
TabButton {
|
||||
text : qsTr("Page3")
|
||||
onClicked: {
|
||||
mStackId.pop()
|
||||
mStackId.push("Page3.qml")
|
||||
console.log("Number of items : " + mStackId.depth)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Main Content
|
||||
StackView {
|
||||
id : mStackId
|
||||
anchors.fill: parent
|
||||
initialItem: Page1{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
|
||||
Rectangle {
|
||||
color: "red"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
|
||||
Rectangle {
|
||||
color: "green"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
|
||||
Rectangle {
|
||||
color: "blue"
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("21-ApplicationWindow", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>images/copyIcon.png</file>
|
||||
<file>images/cutIcon.png</file>
|
||||
<file>images/info.png</file>
|
||||
<file>images/newFileIcon.png</file>
|
||||
<file>images/openIcon.png</file>
|
||||
<file>images/pasteIcon.png</file>
|
||||
<file>images/quitIcon.png</file>
|
||||
<file>images/redoIcon.png</file>
|
||||
<file>images/saveAsIcon.png</file>
|
||||
<file>images/saveIcon.png</file>
|
||||
<file>images/undoIcon.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(3-BusyIndicator 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(app3-BusyIndicator
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app3-BusyIndicator
|
||||
URI 3-BusyIndicator
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app3-BusyIndicator 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(app3-BusyIndicator
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app3-BusyIndicator
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
@@ -0,0 +1,61 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("BusyIndicator")
|
||||
|
||||
ColumnLayout {
|
||||
width: parent.width
|
||||
//height: parent.height
|
||||
|
||||
BusyIndicator{
|
||||
id: busyIndicatorId
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
running: false
|
||||
//visible: false
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Button{
|
||||
id: button1
|
||||
text: "Running"
|
||||
Layout.fillWidth: true
|
||||
onClicked: {
|
||||
busyIndicatorId.running = true
|
||||
//busyIndicatorId.visible = true
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: button2
|
||||
text: "Not Running"
|
||||
Layout.fillWidth: true
|
||||
onClicked: {
|
||||
busyIndicatorId.running = false
|
||||
//busyIndicatorId.visible = false
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "red"
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// 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("3-BusyIndicator", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(4-CheckBox VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_executable(app4-CheckBox
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app4-CheckBox
|
||||
URI 4-CheckBox
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app4-CheckBox 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(app4-CheckBox
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
install(TARGETS app4-CheckBox
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
39
Qt6QMLBeginnersCode/8-QtQuickControls/4-CheckBox/Main.qml
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Window
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("CheckBox")
|
||||
|
||||
Column {
|
||||
spacing: 20
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
CheckBox {
|
||||
text: "Option1"
|
||||
checked: true
|
||||
onCheckStateChanged: {
|
||||
if (checked)
|
||||
{
|
||||
console.log("Option1 is checked")
|
||||
}else{
|
||||
console.log("Option1 is unchecked")
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckBox {
|
||||
text: "Option2"
|
||||
}
|
||||
CheckBox {
|
||||
text: "Option3"
|
||||
checked: false
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Qt6QMLBeginnersCode/8-QtQuickControls/4-CheckBox/main.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("4-CheckBox", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(5-ComboBox 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(app5-ComboBox
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app5-ComboBox
|
||||
URI 5-ComboBox
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app5-ComboBox 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(app5-ComboBox
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app5-ComboBox
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
90
Qt6QMLBeginnersCode/8-QtQuickControls/5-ComboBox/Main.qml
Normal file
@@ -0,0 +1,90 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("ComboBox")
|
||||
|
||||
ColumnLayout{
|
||||
width: parent.width
|
||||
height:parent.height
|
||||
|
||||
//Non Editable ComboBox
|
||||
|
||||
Label {
|
||||
text: "Non Editable Combo"
|
||||
wrapMode: Label.Wrap
|
||||
//horizontalAlignment: Qt.AlignHCenter
|
||||
//width: parent.width
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
id: nonEditableComboId
|
||||
model: ["One", "Two", "Three", "Four"]
|
||||
//anchors.horizontalCenter: parent.horizontalCenter
|
||||
onActivated: {
|
||||
console.log("[" + currentIndex +"] " + currentText + " is activated")
|
||||
}
|
||||
Layout.fillWidth: true
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Editable ComboBox
|
||||
Label {
|
||||
text: "Editable Combo"
|
||||
wrapMode: Label.Wrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
id: editableComboId
|
||||
editable: true
|
||||
textRole : "text"
|
||||
Layout.fillWidth: true
|
||||
model: ListModel {
|
||||
id : model
|
||||
ListElement { text: "Dog"; location:"Kigali" }
|
||||
ListElement { text: "Chicken"; location : "Beijing" }
|
||||
ListElement { text: "Cat" ; location : "Mumbai" }
|
||||
ListElement { text: "Meerkat" ; location : "Paris" }
|
||||
}
|
||||
|
||||
|
||||
onActivated: {
|
||||
console.log("[" + currentIndex +"] " + currentText + " is activated")
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
if ( find(editText) === -1)
|
||||
{
|
||||
model.append({text : editText , location : "US"})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Button{
|
||||
text : "Capture current element"
|
||||
Layout.fillWidth: true
|
||||
onClicked: {
|
||||
console.log("[" + model.get(editableComboId.currentIndex).text +"]: " +
|
||||
model.get(editableComboId.currentIndex).location)
|
||||
}
|
||||
}
|
||||
|
||||
Item{
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Qt6QMLBeginnersCode/8-QtQuickControls/5-ComboBox/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("5-ComboBox", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(6-DelayButton VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.5)
|
||||
|
||||
qt_add_executable(app6-DelayButton
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app6-DelayButton
|
||||
URI 6-DelayButton
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app6-DelayButton 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(app6-DelayButton
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
install(TARGETS app6-DelayButton
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
51
Qt6QMLBeginnersCode/8-QtQuickControls/6-DelayButton/Main.qml
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("DelayButton")
|
||||
|
||||
ColumnLayout {
|
||||
width: parent.width
|
||||
spacing: 40
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
wrapMode: Label.Wrap
|
||||
Layout.fillWidth: true
|
||||
text: "Delayed Button. Use it when you want to prevent accidental clicks"
|
||||
font.pointSize: 15
|
||||
}
|
||||
|
||||
DelayButton {
|
||||
property bool activated: false
|
||||
text: "DelayButton"
|
||||
Layout.fillWidth: true
|
||||
delay: 1000
|
||||
|
||||
onPressed: {
|
||||
if(activated === true)
|
||||
{
|
||||
console.log("Button is Clicked. Carrying out the task")
|
||||
activated = false;
|
||||
}
|
||||
}
|
||||
|
||||
onActivated: {
|
||||
console.log("Button Activated")
|
||||
activated = true
|
||||
}
|
||||
|
||||
onProgressChanged:{
|
||||
console.log(progress)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
19
Qt6QMLBeginnersCode/8-QtQuickControls/6-DelayButton/main.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("6-DelayButton", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
40
Qt6QMLBeginnersCode/8-QtQuickControls/7-Dial/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(7-Dial 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(app7-Dial
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app7-Dial
|
||||
URI 7-Dial
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app7-Dial 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(app7-Dial
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app7-Dial
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
39
Qt6QMLBeginnersCode/8-QtQuickControls/7-Dial/Main.qml
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("Dial")
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 40
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
wrapMode: Label.Wrap
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
text: "A Knob used to let the user choose a value from a range"
|
||||
font.pointSize: 15
|
||||
}
|
||||
|
||||
Dial{
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
from: 1
|
||||
to: 100
|
||||
value: 50
|
||||
wrap: true
|
||||
|
||||
onValueChanged: {
|
||||
console.log(" Current value: " + Math.ceil(value))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
23
Qt6QMLBeginnersCode/8-QtQuickControls/7-Dial/main.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
// 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;
|
||||
//Load our style
|
||||
QQuickStyle::setStyle("Material");
|
||||
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("7-Dial", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
40
Qt6QMLBeginnersCode/8-QtQuickControls/8-Frame/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(8-Frame 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(app8-Frame
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app8-Frame
|
||||
URI 8-Frame
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app8-Frame 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(app8-Frame
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app8-Frame
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
31
Qt6QMLBeginnersCode/8-QtQuickControls/8-Frame/Main.qml
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("Frame")
|
||||
|
||||
Frame {
|
||||
anchors.centerIn: parent
|
||||
|
||||
ColumnLayout {
|
||||
|
||||
Button {
|
||||
text: "Button1"
|
||||
}
|
||||
Button {
|
||||
text: "Button2"
|
||||
}
|
||||
Button {
|
||||
text: "Button3"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Qt6QMLBeginnersCode/8-QtQuickControls/8-Frame/main.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// 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("Universal");
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("8-Frame", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(9-GroupBoxRadioCheckButton 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(app9-GroupBoxRadioCheckButton
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app9-GroupBoxRadioCheckButton
|
||||
URI 9-GroupBoxRadioCheckButton
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app9-GroupBoxRadioCheckButton 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(app9-GroupBoxRadioCheckButton
|
||||
PRIVATE Qt6::Quick Qt6::QuickControls2
|
||||
)
|
||||
|
||||
install(TARGETS app9-GroupBoxRadioCheckButton
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
@@ -0,0 +1,83 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("GroupBox")
|
||||
|
||||
Column{
|
||||
spacing: 10
|
||||
anchors.fill: parent
|
||||
|
||||
//RadioButton controls
|
||||
Label {
|
||||
width: parent.width
|
||||
wrapMode: Label.Wrap
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
text: "A GroupBox wrapping around RadioButtons."
|
||||
}
|
||||
|
||||
GroupBox{
|
||||
title: "Choose bonus"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
Column{
|
||||
|
||||
RadioButton{
|
||||
text: "Coke"
|
||||
onCheckedChanged: {
|
||||
if( checked){
|
||||
console.log("Coke button checked")
|
||||
}else{
|
||||
console.log("Coke button is NOT checked")
|
||||
}
|
||||
}
|
||||
}
|
||||
RadioButton{
|
||||
text: "Green Tea"
|
||||
}
|
||||
RadioButton{
|
||||
text: "Ice Cream"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//CheckBox Controls
|
||||
Label {
|
||||
width: parent.width
|
||||
wrapMode: Label.Wrap
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
text: "A GroupBox wrapping around CheckBoxes."
|
||||
}
|
||||
|
||||
|
||||
GroupBox{
|
||||
title: "Choose Qt supported Desktop Platform"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
Column{
|
||||
|
||||
CheckBox{
|
||||
text: "Windows"
|
||||
onCheckedChanged: {
|
||||
if( checked){
|
||||
console.log("Windows button checked")
|
||||
}else{
|
||||
console.log("Windows button is NOT checked")
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckBox{
|
||||
text: "Mac"
|
||||
}
|
||||
CheckBox{
|
||||
text: "Linux"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// 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("Universal");
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule("9-GroupBoxRadioCheckButton", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||