From 3a76c3ef8ee5a7464c1fd872f312d4dd15937dda Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 9 May 2019 23:22:51 +0800 Subject: add some qt project template --- .../c++/quickapp_qt_static/project/src/main.cpp | 16 ++++++++++ .../c++/quickapp_qt_static/project/src/main.qml | 9 ++++++ .../c++/quickapp_qt_static/project/src/qml.qrc | 5 ++++ .../c++/quickapp_qt_static/project/xmake.lua | 34 +++++++++++++++++++++ .../templates/c++/quickapp_qt_static/template.lua | 15 ++++++++++ .../c++/widgetapp_qt/project/src/main.cpp | 11 +++++++ .../c++/widgetapp_qt/project/src/mainwindow.cpp | 14 +++++++++ .../c++/widgetapp_qt/project/src/mainwindow.h | 22 ++++++++++++++ .../c++/widgetapp_qt/project/src/mainwindow.ui | 24 +++++++++++++++ xmake/templates/c++/widgetapp_qt/project/xmake.lua | 23 ++++++++++++++ xmake/templates/c++/widgetapp_qt/template.lua | 15 ++++++++++ .../c++/widgetapp_qt_static/project/src/main.cpp | 11 +++++++ .../widgetapp_qt_static/project/src/mainwindow.cpp | 14 +++++++++ .../widgetapp_qt_static/project/src/mainwindow.h | 22 ++++++++++++++ .../widgetapp_qt_static/project/src/mainwindow.ui | 24 +++++++++++++++ .../c++/widgetapp_qt_static/project/xmake.lua | 35 ++++++++++++++++++++++ .../templates/c++/widgetapp_qt_static/template.lua | 15 ++++++++++ 17 files changed, 309 insertions(+) create mode 100644 xmake/templates/c++/quickapp_qt_static/project/src/main.cpp create mode 100644 xmake/templates/c++/quickapp_qt_static/project/src/main.qml create mode 100644 xmake/templates/c++/quickapp_qt_static/project/src/qml.qrc create mode 100644 xmake/templates/c++/quickapp_qt_static/project/xmake.lua create mode 100644 xmake/templates/c++/quickapp_qt_static/template.lua create mode 100644 xmake/templates/c++/widgetapp_qt/project/src/main.cpp create mode 100644 xmake/templates/c++/widgetapp_qt/project/src/mainwindow.cpp create mode 100644 xmake/templates/c++/widgetapp_qt/project/src/mainwindow.h create mode 100644 xmake/templates/c++/widgetapp_qt/project/src/mainwindow.ui create mode 100644 xmake/templates/c++/widgetapp_qt/project/xmake.lua create mode 100644 xmake/templates/c++/widgetapp_qt/template.lua create mode 100644 xmake/templates/c++/widgetapp_qt_static/project/src/main.cpp create mode 100644 xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.cpp create mode 100644 xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.h create mode 100644 xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.ui create mode 100644 xmake/templates/c++/widgetapp_qt_static/project/xmake.lua create mode 100644 xmake/templates/c++/widgetapp_qt_static/template.lua diff --git a/xmake/templates/c++/quickapp_qt_static/project/src/main.cpp b/xmake/templates/c++/quickapp_qt_static/project/src/main.cpp new file mode 100644 index 000000000..6333b85c4 --- /dev/null +++ b/xmake/templates/c++/quickapp_qt_static/project/src/main.cpp @@ -0,0 +1,16 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (engine.rootObjects().isEmpty()) + return -1; + + return app.exec(); +} diff --git a/xmake/templates/c++/quickapp_qt_static/project/src/main.qml b/xmake/templates/c++/quickapp_qt_static/project/src/main.qml new file mode 100644 index 000000000..188049dae --- /dev/null +++ b/xmake/templates/c++/quickapp_qt_static/project/src/main.qml @@ -0,0 +1,9 @@ +import QtQuick 2.9 +import QtQuick.Window 2.2 + +Window { + visible: true + width: 640 + height: 480 + title: qsTr("Hello World") +} diff --git a/xmake/templates/c++/quickapp_qt_static/project/src/qml.qrc b/xmake/templates/c++/quickapp_qt_static/project/src/qml.qrc new file mode 100644 index 000000000..5f6483ac3 --- /dev/null +++ b/xmake/templates/c++/quickapp_qt_static/project/src/qml.qrc @@ -0,0 +1,5 @@ + + + main.qml + + diff --git a/xmake/templates/c++/quickapp_qt_static/project/xmake.lua b/xmake/templates/c++/quickapp_qt_static/project/xmake.lua new file mode 100644 index 000000000..1978bf5bf --- /dev/null +++ b/xmake/templates/c++/quickapp_qt_static/project/xmake.lua @@ -0,0 +1,34 @@ + +-- add modes: debug and release +add_rules("mode.debug", "mode.release") + +-- includes +includes("qt_add_static_plugins.lua") + +-- add target +target("[targetname]") + + -- add rules + add_rules("qt.application") + + -- add headers + add_headerfiles("src/*.h") + + -- add files + add_files("src/*.cpp") + add_files("src/qml.qrc") + + -- add frameworks + add_frameworks("QtQuick") + + -- add plugin: QXXXIntegrationPlugin + if is_plat("macosx") then + qt_add_static_plugins("QCocoaIntegrationPlugin", {linkdirs = "plugins/platforms", links = {"qcocoa", "Qt5PrintSupport", "Qt5PlatformSupport", "Qt5Widgets", "cups"}}) + elseif is_plat("windows") then + qt_add_static_plugins("QWindowsIntegrationPlugin", {linkdirs = "plugins/platforms", links = {"Qt5PrintSupport", "Qt5PlatformSupport", "Qt5Widgets", "qwindows"}}) + end + + -- add plugin: qml.QtQuick + qt_add_static_plugins("QtQuick2Plugin", {linkdirs = "qml/QtQuick.2", links = "qtquick2plugin"}) + qt_add_static_plugins("QtQuick2WindowPlugin", {linkdirs = "qml/QtQuick/Window.2", links = "windowplugin"}) + diff --git a/xmake/templates/c++/quickapp_qt_static/template.lua b/xmake/templates/c++/quickapp_qt_static/template.lua new file mode 100644 index 000000000..1efa5b9aa --- /dev/null +++ b/xmake/templates/c++/quickapp_qt_static/template.lua @@ -0,0 +1,15 @@ +-- set name +set_name("quickapp_qt") + +-- set description +set_description("The Quick Application (Qt)") + +-- set project directory +set_projectdir("project") + +-- add macros +add_macros("targetname", "$(targetname)") + +-- add macro files +add_macrofiles("xmake.lua") + diff --git a/xmake/templates/c++/widgetapp_qt/project/src/main.cpp b/xmake/templates/c++/widgetapp_qt/project/src/main.cpp new file mode 100644 index 000000000..b48f94ec8 --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt/project/src/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/xmake/templates/c++/widgetapp_qt/project/src/mainwindow.cpp b/xmake/templates/c++/widgetapp_qt/project/src/mainwindow.cpp new file mode 100644 index 000000000..49d64fce7 --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt/project/src/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/xmake/templates/c++/widgetapp_qt/project/src/mainwindow.h b/xmake/templates/c++/widgetapp_qt/project/src/mainwindow.h new file mode 100644 index 000000000..8e06f4918 --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt/project/src/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/xmake/templates/c++/widgetapp_qt/project/src/mainwindow.ui b/xmake/templates/c++/widgetapp_qt/project/src/mainwindow.ui new file mode 100644 index 000000000..1c59b695e --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt/project/src/mainwindow.ui @@ -0,0 +1,24 @@ + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + + + + + + diff --git a/xmake/templates/c++/widgetapp_qt/project/xmake.lua b/xmake/templates/c++/widgetapp_qt/project/xmake.lua new file mode 100644 index 000000000..ca522ec40 --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt/project/xmake.lua @@ -0,0 +1,23 @@ + +-- add modes: debug and release +add_rules("mode.debug", "mode.release") + +-- add target +target("[targetname]") + + -- add rules + add_rules("qt.application") + + -- add headers + add_headerfiles("src/*.h") + + -- add files + add_files("src/*.cpp") + add_files("src/mainwindow.ui") + + -- add files with Q_OBJECT meta (only for qt.moc) + add_files("src/mainwindow.h") + + -- add frameworks + add_frameworks("QtWidgets") + diff --git a/xmake/templates/c++/widgetapp_qt/template.lua b/xmake/templates/c++/widgetapp_qt/template.lua new file mode 100644 index 000000000..668b32bce --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt/template.lua @@ -0,0 +1,15 @@ +-- set name +set_name("widgetapp_qt") + +-- set description +set_description("The Widget Application (Qt)") + +-- set project directory +set_projectdir("project") + +-- add macros +add_macros("targetname", "$(targetname)") + +-- add macro files +add_macrofiles("xmake.lua") + diff --git a/xmake/templates/c++/widgetapp_qt_static/project/src/main.cpp b/xmake/templates/c++/widgetapp_qt_static/project/src/main.cpp new file mode 100644 index 000000000..b48f94ec8 --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt_static/project/src/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.cpp b/xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.cpp new file mode 100644 index 000000000..49d64fce7 --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.h b/xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.h new file mode 100644 index 000000000..8e06f4918 --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.ui b/xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.ui new file mode 100644 index 000000000..1c59b695e --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt_static/project/src/mainwindow.ui @@ -0,0 +1,24 @@ + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + + + + + + diff --git a/xmake/templates/c++/widgetapp_qt_static/project/xmake.lua b/xmake/templates/c++/widgetapp_qt_static/project/xmake.lua new file mode 100644 index 000000000..26ce15e15 --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt_static/project/xmake.lua @@ -0,0 +1,35 @@ + +-- add modes: debug and release +add_rules("mode.debug", "mode.release") + +-- includes +includes("qt_add_static_plugins.lua") + +-- add target +target("[targetname]") + + -- add rules + add_rules("qt.application") + + -- add headers + add_headerfiles("src/*.h") + + -- add files + add_files("src/*.cpp") + add_files("src/mainwindow.ui") + + -- add files with Q_OBJECT meta (only for qt.moc) + add_files("src/mainwindow.h") + + -- add frameworks + add_frameworks("QtWidgets") + + -- add plugin: QXXXIntegrationPlugin + if is_plat("macosx") then + qt_add_static_plugins("QCocoaIntegrationPlugin", {linkdirs = "plugins/platforms", links = {"qcocoa", "Qt5PrintSupport", "Qt5PlatformSupport", "cups"}}) + elseif is_plat("windows") then + qt_add_static_plugins("QWindowsIntegrationPlugin", {linkdirs = "plugins/platforms", links = {"Qt5PrintSupport", "Qt5PlatformSupport", "qwindows"}}) + end + + -- add plugin: QSvgPlugin (optional) + qt_add_static_plugins("QSvgPlugin", {linkdirs = "plugins/imageformats", links = {"qsvg", "Qt5Svg"}}) diff --git a/xmake/templates/c++/widgetapp_qt_static/template.lua b/xmake/templates/c++/widgetapp_qt_static/template.lua new file mode 100644 index 000000000..668b32bce --- /dev/null +++ b/xmake/templates/c++/widgetapp_qt_static/template.lua @@ -0,0 +1,15 @@ +-- set name +set_name("widgetapp_qt") + +-- set description +set_description("The Widget Application (Qt)") + +-- set project directory +set_projectdir("project") + +-- add macros +add_macros("targetname", "$(targetname)") + +-- add macro files +add_macrofiles("xmake.lua") + -- cgit v1.3.1