add book
This commit is contained in:
40
Qt6QMLBeginnersCode/5.UserInput/2-TextEdit/CMakeLists.txt
Normal file
40
Qt6QMLBeginnersCode/5.UserInput/2-TextEdit/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) Daniel Gakwaya.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(2-TextEdit 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(app2-TextEdit
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(app2-TextEdit
|
||||
URI 2-TextEdit
|
||||
VERSION 1.0
|
||||
QML_FILES Main.qml
|
||||
)
|
||||
|
||||
set_target_properties(app2-TextEdit 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-TextEdit
|
||||
PRIVATE Qt6::Quick
|
||||
)
|
||||
|
||||
install(TARGETS app2-TextEdit
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
69
Qt6QMLBeginnersCode/5.UserInput/2-TextEdit/Main.qml
Normal file
69
Qt6QMLBeginnersCode/5.UserInput/2-TextEdit/Main.qml
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) Daniel Gakwaya.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("TextEdit Demo")
|
||||
|
||||
|
||||
|
||||
/*
|
||||
TextEdit {
|
||||
id: textInputId
|
||||
width: 240
|
||||
anchors.centerIn: parent
|
||||
|
||||
text: "<strong>Because</strong> we want to use our server locally, we set our domain name \r to be <font color = 'red' >localhost </font>. If we had set it up to\n be something else, we would have to go mess with the host files to resolve whatever we put in here to a recognizable network address. ustleaveinlocalhostitisgoodenoughforourlocalusepurposes. Leave the rest to defaults and hit continue. You are then given a choice for the database you want to use"
|
||||
|
||||
wrapMode: TextEdit.Wrap
|
||||
//textFormat: TextEdit.RichText
|
||||
font.family: "Helvetica"
|
||||
font.pointSize: 20
|
||||
color: "blue"
|
||||
focus: true
|
||||
|
||||
onEditingFinished: {
|
||||
console.log("The current text is: "+ text)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
TextEdit {
|
||||
id: textInputId
|
||||
wrapMode: TextEdit.Wrap
|
||||
textFormat: TextEdit.RichText
|
||||
width: 240
|
||||
//text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
||||
text: "<strong>Because</strong> we want to use our server locally, we set our domain name \r to be <font color = 'red' >localhost </font>."
|
||||
|
||||
font.family: "Helvetica"
|
||||
font.pointSize: 20
|
||||
color: "blue"
|
||||
focus: true
|
||||
|
||||
onEditingFinished: {
|
||||
console.log("The current text is: "+ text)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Rectangle {
|
||||
id: mRectId
|
||||
width: 240
|
||||
height: 100
|
||||
color: "red"
|
||||
anchors.top: textInputId.bottom
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
console.log("The new text is: "+textInputId.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
19
Qt6QMLBeginnersCode/5.UserInput/2-TextEdit/main.cpp
Normal file
19
Qt6QMLBeginnersCode/5.UserInput/2-TextEdit/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("2-TextEdit", "Main");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user