This commit is contained in:
2025-09-28 17:05:51 +08:00
parent 8eb80ab66d
commit d97fa3e0fe
398 changed files with 18737 additions and 0 deletions

View File

@@ -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}
)

View 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"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

View 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();
}

View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>images/drawer.png</file>
</qresource>
</RCC>