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-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
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
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();
|
||||
}
|
||||
Reference in New Issue
Block a user