Skip to content

Commit

Permalink
增加 入门指南.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jared2020 committed Nov 21, 2020
1 parent a832e72 commit 9661f6f
Show file tree
Hide file tree
Showing 22 changed files with 699 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ CusConfig是核心库的全局配置,主要包括字体、颜色等,所有组件

## 使用核心库TaoQuick

详细的使用方法,可以阅读 [入门指南](入门指南.md)

### qmake用法

使用核心库,只需要在项目中导入'.pri'文件,并将qml路径加入到QmlEngine即可。
Expand Down Expand Up @@ -307,6 +309,9 @@ debug模式都以本地文件的方式使用,release模型则以qrc资源文

### cmake用法

详细的使用方法,可以阅读 [入门指南](入门指南.md)


TaoQuick 0.5.0以后的版本,增加了cmake支持。

原理和qmake一样,只不过换成了cmake的语法规则。
Expand Down
Binary file added doc/cmake1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/cmake2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/cmake3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/cmake4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/cmake5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/cmake6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/start1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/start2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/start3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/start4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/start5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions examples/HelloTaoQuick1/HelloTaoQuick1.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
TEMPLATE = app

QT += gui quick qml quickcontrols2

SOURCES += main.cpp

RESOURCES += Res.qrc

include(../../src/TaoQuick/TaoQuick.pri)
5 changes: 5 additions & 0 deletions examples/HelloTaoQuick1/Res.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
16 changes: 16 additions & 0 deletions examples/HelloTaoQuick1/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <QQuickView>
#include <QQmlEngine>
#include <QQmlContext>
#include <QGuiApplication>
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
QQuickView view;
view.engine()->addImportPath(TaoQuickImportPath);
view.rootContext()->setContextProperty("taoQuickImagePath", TaoQuickImagePath);

view.setSource(QUrl("qrc:/main.qml"));
view.show();

return app.exec();
}
21 changes: 21 additions & 0 deletions examples/HelloTaoQuick1/main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import QtQml 2.0
import QtQuick 2.9

import QtQuick.Controls 2.0

import TaoQuick 1.0

Rectangle {
color: "lightblue"
width: 640
height: 480
CusButton_Blue {
width: 120
height: 36
anchors.centerIn: parent
text: "Hello"
onClicked: {
console.log("hello TaoQuick")
}
}
}
35 changes: 35 additions & 0 deletions examples/HelloTaoQuick2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.14)

project(HelloTaoQuick2 LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(taoQuick.cmake)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)

if(ANDROID)
add_library(HelloTaoQuick2 SHARED
main.cpp
qml.qrc
)
else()
add_executable(HelloTaoQuick2
main.cpp
qml.qrc
${TaoQuickRes}
)
endif()

target_compile_definitions(HelloTaoQuick2
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(HelloTaoQuick2
PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick)
22 changes: 22 additions & 0 deletions examples/HelloTaoQuick2/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

QGuiApplication app(argc, argv);

QQmlApplicationEngine engine;
engine.addImportPath(TaoQuickImportPath);
engine.rootContext()->setContextProperty("taoQuickImagePath", TaoQuickImagePath);
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);

return app.exec();
}
19 changes: 19 additions & 0 deletions examples/HelloTaoQuick2/main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick 2.9
import TaoQuick 1.0
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
CusButton_Blue {
width: 120
height: 36
anchors.centerIn: parent
text: "Hello"
onClicked: {
console.log("hello TaoQuick")
}
}
}
5 changes: 5 additions & 0 deletions examples/HelloTaoQuick2/qml.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
19 changes: 19 additions & 0 deletions examples/HelloTaoQuick2/taoQuick.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(TaoQuickPath ${CMAKE_SOURCE_DIR}/../../src/TaoQuick/imports)

if (CMAKE_BUILD_TYPE MATCHES "Release")
set(TaoQuickRes ${TaoQuickPath}/TaoQuick/TaoQuick.qrc CACHE STRING "tao quick res path")
set(TaoQuickImportPath "qrc:///" CACHE STRING "tao quick import path")
set(TaoQuickImagePath "qrc:/TaoQuick/Images/" CACHE STRING "tao quick image path")

else()
set(TaoQuickImportPath "file:///${TaoQuickPath}" CACHE STRING "tao quick import path")
set(TaoQuickImagePath "file:///${TaoQuickPath}/TaoQuick/Images/" CACHE STRING "tao quick image path")
endif()
add_compile_definitions(TaoQuickImportPath="${TaoQuickImportPath}")
add_compile_definitions(TaoQuickImagePath="${TaoQuickImagePath}")

add_compile_definitions(QML_IMPORT_PATH="${TaoQuickPath}")
add_compile_definitions(QML2_IMPORT_PATH="${TaoQuickPath}")
add_compile_definitions(QML_DESIGNER_IMPORT_PATH="${TaoQuickPath}")


Loading

0 comments on commit 9661f6f

Please sign in to comment.