Initial minimal project.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# Common project properties
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILT_TYPE Debug CACHE STRING "Choose the type of build, options are: Debug Release" FORCE)
|
||||
endif()
|
||||
|
||||
# 3rd party tools
|
||||
find_package(Qt5 COMPONENTS Widgets Qml Quick REQUIRED)
|
||||
|
||||
# Directory with the source code
|
||||
add_subdirectory(src)
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# Minimal Qt QML Project
|
||||
|
||||
This is minimal program that uses Qt Qml for creating user interface library
|
||||
and using CMake as build system.
|
||||
|
||||
## Built With
|
||||
|
||||
* [CMake](http://cmake.org/) - Build system (>=5.7 is required).
|
||||
* [Qt](http://www.qt.io/) - Cross-platform library (>=2.8 is required).
|
||||
|
||||
## Getting Started
|
||||
|
||||
Install the following packages to prepare the build.
|
||||
|
||||
### Ubuntu & Debian
|
||||
|
||||
* Ubuntu 16.04
|
||||
* Debian 9
|
||||
|
||||
```
|
||||
sudo apt-get install -y build-essential cmake qtbase5-dev qtdeclarative5-dev qml-module-qtquick2 qtquickcontrols2-5-dev qml-module-qtquick-controls
|
||||
```
|
||||
|
||||
### Fedora & CentOS
|
||||
|
||||
* CentOS 7
|
||||
* Fedora >=20
|
||||
|
||||
```
|
||||
sudo yum groupinstall -y "Development Tools"
|
||||
sudo yum install -y cmake qt5-qtbase-devel qt5-qtdeclarative-devel qt5-qtquickcontrols qt5-qtquickcontrols2-devel
|
||||
```
|
||||
|
||||
### Build Solution
|
||||
|
||||
Call the build of the solution and launch the application:
|
||||
|
||||
```
|
||||
cd <PathToProject>
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
./src/MinimalQml &
|
||||
```
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
include_directories(${Qt5Widgets_INCLUDE_DIRS} ${QtQml_INCLUDE_DIRS})
|
||||
add_definitions(${Qt5Widgets_DEFINITIONS} ${QtQml_DEFINITIONS} ${${Qt5Quick_DEFINITIONS}})
|
||||
|
||||
qt5_add_resources(QT_RESOURCES qml.qrc)
|
||||
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG")
|
||||
endif()
|
||||
|
||||
|
||||
set(PROJECT "MinimalQml")
|
||||
|
||||
project(${PROJECT})
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=c++11 -fstrict-aliasing -pedantic-errors -pedantic -Wno-deprecated-declarations -Wno-unused-variable")
|
||||
|
||||
if(NOT DEFINED HEADERS)
|
||||
file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED SOURCES)
|
||||
file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||
endif()
|
||||
|
||||
source_group("Header Files" FILES ${HEADERS})
|
||||
source_group("Source Files" FILES ${SOURCES})
|
||||
|
||||
|
||||
add_executable(${PROJECT} ${HEADERS} ${SOURCES} ${QT_RESOURCES})
|
||||
|
||||
target_link_libraries(${PROJECT}
|
||||
Qt5::Widgets
|
||||
Qt5::Qml
|
||||
Qt5::Quick
|
||||
)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "stdafx.h"
|
||||
#include <QApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QMessageBox>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
|
||||
int result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
result = app.exec();
|
||||
}
|
||||
catch(const std::exception& ex)
|
||||
{
|
||||
QString message = ex.what();
|
||||
QMessageBox::critical(nullptr, qtTrId("Error"), message);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import QtQuick 2.6
|
||||
import QtQuick.Layouts 1.0
|
||||
import QtQuick.Controls 1.0
|
||||
|
||||
ApplicationWindow
|
||||
{
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("Minimal Qml")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>qmldir</file>
|
||||
<file>main.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
|
||||
Reference in New Issue
Block a user