diff options
| author | ruki <[email protected]> | 2019-05-09 23:22:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-05-09 14:17:09 +0800 |
| commit | 3a76c3ef8ee5a7464c1fd872f312d4dd15937dda (patch) | |
| tree | 53a7c26e760893d32ea3aa6174408315a2a6f95f | |
| parent | 916c855f1703b84e323b2531a61c7d60fefbb61d (diff) | |
add some qt project template
17 files changed, 309 insertions, 0 deletions
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 <QGuiApplication> +#include <QQmlApplicationEngine> + +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 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> 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 <QApplication> + +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 <QMainWindow> + +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 @@ +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle" > + <string>MainWindow</string> + </property> + <widget class="QMenuBar" name="menuBar" /> + <widget class="QToolBar" name="mainToolBar" /> + <widget class="QWidget" name="centralWidget" /> + <widget class="QStatusBar" name="statusBar" /> + </widget> + <layoutDefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections/> +</ui> 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 <QApplication> + +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 <QMainWindow> + +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 @@ +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle" > + <string>MainWindow</string> + </property> + <widget class="QMenuBar" name="menuBar" /> + <widget class="QToolBar" name="mainToolBar" /> + <widget class="QWidget" name="centralWidget" /> + <widget class="QStatusBar" name="statusBar" /> + </widget> + <layoutDefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections/> +</ui> 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") + |
