From 62e57ba339263e0737ec28418bf3fe730535f675 Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Fri, 08 Apr 2022 11:01:44 +0800 Subject: [PATCH] Add QT hello example source code and build shell script --- qt/hello/qml.qrc | 6 ++ qt/hello/MainForm.ui.qml | 18 ++++++ qt/hello/build.sh | 22 +++++++ qt/hello/main.cpp | 12 ++++ qt/hello/main.qml | 78 ++++++++++++++++++++++++++ 5 files changed, 136 insertions(+), 0 deletions(-) diff --git a/qt/hello/MainForm.ui.qml b/qt/hello/MainForm.ui.qml new file mode 100644 index 0000000..dd8fcab --- /dev/null +++ b/qt/hello/MainForm.ui.qml @@ -0,0 +1,18 @@ +import QtQuick 2.5 + +Rectangle { + property alias mouseArea: mouseArea + + width: 360 + height: 360 + + MouseArea { + id: mouseArea + anchors.fill: parent + } + + Text { + anchors.centerIn: parent + text: "Hello World" + } +} diff --git a/qt/hello/build.sh b/qt/hello/build.sh new file mode 100755 index 0000000..4aa2aca --- /dev/null +++ b/qt/hello/build.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# export qmake command path +export PATH=$PATH:/apps/qt5_rpi/bin/ + +# project name is current working directory name +PRJ_NAME=$(basename `pwd`) + +# generate project file +rm -f ${PRJ_NAME}.pro +qmake -project + +# Add qml support to fix bug: QQmlApplicationEngine: No such file or directory +echo "QT += qml" >> ${PRJ_NAME}.pro + +# generate makefile +qmake -makefile ${PRJ_NAME}.pro + + +# start to cross compile +make && make clean + diff --git a/qt/hello/main.cpp b/qt/hello/main.cpp new file mode 100644 index 0000000..4e72baa --- /dev/null +++ b/qt/hello/main.cpp @@ -0,0 +1,12 @@ +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/qt/hello/main.qml b/qt/hello/main.qml new file mode 100644 index 0000000..ef857da --- /dev/null +++ b/qt/hello/main.qml @@ -0,0 +1,78 @@ +import QtQuick 2.5 +import QtQuick.Window 2.2 + +Window { + visible: true + width: 640 + height: 480 + title: qsTr("Hello World") + + MainForm { + anchors.fill: parent + mouseArea.onClicked: { + Qt.quit(); + } + + Text { + id: text1 + x: 131 + y: 136 + width: 100 + height: 20 + text: "192.168.1.10" + font.pixelSize: 12 + } + + TextInput { + id: textInput1 + x: 45 + y: 136 + width: 80 + height: 20 + text: "IP地址" + font.pixelSize: 12 + } + + TextEdit { + id: textEdit1 + x: 261 + y: 136 + width: 80 + height: 20 + text: qsTr("Text Edit") + font.pixelSize: 12 + } + + Rectangle { + id: rectangle1 + x: 380 + y: 165 + width: 200 + height: 200 + color: "#ffffff" + } + + Image { + id: image1 + x: 25 + y: 245 + width: 100 + height: 100 + source: "qrc:/qtquickplugin/images/template_image.png" + } + + Item { + id: item1 + x: 149 + y: 187 + width: 200 + height: 200 + } + + MainForm { + id: mainForm1 + x: 163 + y: 52 + } + } +} diff --git a/qt/hello/qml.qrc b/qt/hello/qml.qrc new file mode 100644 index 0000000..4e1a206 --- /dev/null +++ b/qt/hello/qml.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>MainForm.ui.qml</file> + </qresource> +</RCC> -- Gitblit v1.9.1