Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneGockeln committed Nov 11, 2017
1 parent 73b8a5d commit a17039e
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
*.exe
*.out
*.app

# macOS
.DS_Store
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.8)
project(qtstarter)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Qt
# Set this to your Qt installation
set(CMAKE_PREFIX_PATH ~/sourcecode/sdk/QtLatest/5.9.2/clang_64)
set(RESOURCE_FOLDER res)
set(RESOURCE_FILES ${RESOURCE_FOLDER}/resources.qrc)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

find_package(Qt5Core REQUIRED)
find_package(Qt5Quick REQUIRED)

set(SOURCE_FILES main.cpp)

add_executable(qtstarter ${SOURCE_FILES} ${RESOURCE_FILES})

target_link_libraries(qtstarter Qt5::Core Qt5::Quick)
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# qtstarter
C++/Qt5 CLion starter project with cmake build system
C++/Qt5 CLion starter project with cmake build system and QtQuick support.

## Usage
Just clone or download the release and edit the CMakeList.txt to your needs. Especially the `CMAKE_PREFIX_PATH` variable. Set it to your Qt clang_64 path.

## Test
Tested with the following environment:

- macOS Sierra 10.12.6
- CLion 2017.2.3
- Qt 5.9.2 clang_64
- CMake 3.10.0-rc1

15 changes: 15 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <QtCore>
#include <QGuiApplication>
#include <QtQuick/QQuickView>

int main(int argc, char *argv[]) {

QGuiApplication app(argc, argv);

// Set qml file
QQuickView viewer;
viewer.setSource(QUrl("qrc:/views/main.qml"));
viewer.show();

return app.exec();
}
6 changes: 6 additions & 0 deletions res/resources.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="/">
<file>views/main.qml</file>
</qresource>
</RCC>
10 changes: 10 additions & 0 deletions res/views/main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import QtQuick 2.0

Rectangle {
width: 360
height: 360
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
}

0 comments on commit a17039e

Please sign in to comment.