updated chapter 03 tutorial to use CmakeLists.txt and proper build commands
This commit is contained in:
parent
fc72a95aaf
commit
7c4eac807b
@ -17,15 +17,13 @@ qtdeclarative5-dev qtdeclarative5-private-dev libqt5svg5-dev`.
|
|||||||
|
|
||||||
Then we can build and install QSkinny to `/opt/qskinny` with the following commands:
|
Then we can build and install QSkinny to `/opt/qskinny` with the following commands:
|
||||||
|
|
||||||
[source,xml]
|
[source,shell]
|
||||||
....
|
....
|
||||||
cd /home/user/dev/
|
$ git clone https://github.com/uwerat/qskinny.git
|
||||||
git clone https://github.com/uwerat/qskinny.git
|
$ cd qskinny
|
||||||
cd qskinny
|
$ mkdir build && cd build
|
||||||
mkdir build
|
$ cmake ../ && make
|
||||||
cd build
|
$ sudo make install
|
||||||
cmake ../ && make
|
|
||||||
sudo make install
|
|
||||||
....
|
....
|
||||||
|
|
||||||
=== Compiling our first app
|
=== Compiling our first app
|
||||||
@ -52,40 +50,49 @@ int main( int argc, char* argv[] )
|
|||||||
For now this will just create an empty window (the `QskWindow`) without any controls.
|
For now this will just create an empty window (the `QskWindow`) without any controls.
|
||||||
Next, we need to create a `myapp.pro` file in our `myapp` directory.
|
Next, we need to create a `myapp.pro` file in our `myapp` directory.
|
||||||
|
|
||||||
.myapp.pro
|
.CMakeLists.txt
|
||||||
[source,xml]
|
[source,cmake]
|
||||||
....
|
....
|
||||||
TEMPLATE = app
|
cmake_minimum_required(VERSION 3.27)
|
||||||
TARGET = myapp
|
|
||||||
|
|
||||||
QT *= quick
|
project(myapp
|
||||||
|
VERSION 1.0.0
|
||||||
|
LANGUAGES CXX)
|
||||||
|
|
||||||
QSK_ROOT=/opt/qskinny
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
INCLUDEPATH += $${QSK_ROOT}/include
|
set(CMAKE_AUTOMOC ON)
|
||||||
LIBS += -L$${QSK_ROOT}/lib -lqskinny
|
set(CMAKE_AUTORCC ON)
|
||||||
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
|
||||||
QMAKE_RPATHDIR *= $${QSK_ROOT}/lib
|
find_package(Qt5 REQUIRED COMPONENTS Widgets Quick)
|
||||||
|
find_package(QSkinny REQUIRED)
|
||||||
|
|
||||||
SOURCES += \
|
add_executable(myapp
|
||||||
main.cpp
|
src/main.cpp)
|
||||||
|
|
||||||
|
target_link_libraries(kue PRIVATE
|
||||||
|
Qt5::Widgets
|
||||||
|
Qt5::Quick
|
||||||
|
QSkinny::QSkinny)
|
||||||
....
|
....
|
||||||
|
|
||||||
Now we can compile our app:
|
Now we can compile our app:
|
||||||
|
|
||||||
[source,xml]
|
[source,shell]
|
||||||
....
|
....
|
||||||
cd myapp
|
$ cd myapp
|
||||||
qmake
|
$ mkdir build && cd build
|
||||||
make
|
$ cmake ../ && make
|
||||||
....
|
....
|
||||||
|
|
||||||
When running myapp it needs to find the skin plugins. Setting QT_PLUGIN_PATH is one
|
When running myapp it needs to find the skin plugins. Setting QT_PLUGIN_PATH is one
|
||||||
option ( see https://doc.qt.io/qt-5/deployment-plugins.html ):
|
option ( see https://doc.qt.io/qt-5/deployment-plugins.html ):
|
||||||
|
|
||||||
[source,xml]
|
[source,shell]
|
||||||
....
|
....
|
||||||
QT_PLUGIN_PATH=/opt/qskinny/plugins ./myapp
|
$ QT_PLUGIN_PATH=/opt/qskinny/plugins ./myapp
|
||||||
....
|
....
|
||||||
|
|
||||||
This should show just an empty window.
|
This should show just an empty window.
|
||||||
@ -95,7 +102,7 @@ This should show just an empty window.
|
|||||||
Now that we have our app running, we can add some UI controls to it by extending the `main.cpp` file we created earlier. We will add some additional include directives, and then create a horizontal layout containing two push buttons. The layout with the two buttons will be shown in the window. Below is the complete updated source file:
|
Now that we have our app running, we can add some UI controls to it by extending the `main.cpp` file we created earlier. We will add some additional include directives, and then create a horizontal layout containing two push buttons. The layout with the two buttons will be shown in the window. Below is the complete updated source file:
|
||||||
|
|
||||||
.main.cpp
|
.main.cpp
|
||||||
[source]
|
[source, cpp]
|
||||||
....
|
....
|
||||||
#include <QskWindow.h>
|
#include <QskWindow.h>
|
||||||
#include <QskLinearBox.h>
|
#include <QskLinearBox.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user