Skip to content

Commit daa0885

Browse files
author
Kimmo
committed
proper quick project
1 parent 28f25aa commit daa0885

File tree

12 files changed

+234
-0
lines changed

12 files changed

+234
-0
lines changed

quick_project/.tmcrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
Xvfb :1 -screen 0 1024x768x24 +extension RANDR +extension RENDER +extension GLX &
3+
export DISPLAY=:1

quick_project/quick_project.pro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
TEMPLATE = subdirs
2+
SUBDIRS += \
3+
src \
4+
test_runner
5+
6+
test_runner.depends = src

quick_project/src/Clicker.qml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import QtQuick 2.9
2+
import QtQuick.Dialogs 1.1
3+
import QtQuick.Controls 1.0
4+
5+
Item {
6+
id: clicker
7+
anchors.fill: parent
8+
9+
property int click: 0
10+
property alias status: clickerText
11+
property string clickedType : "Generic"
12+
13+
Image {
14+
id: image
15+
anchors.fill: parent
16+
fillMode: Image.PreserveAspectFit
17+
source: "qrc:/smile.png"
18+
19+
MouseArea {
20+
anchors.fill: parent
21+
22+
onClicked: {
23+
click++;
24+
}
25+
}
26+
}
27+
28+
Text {
29+
anchors.horizontalCenter: parent.horizontalCenter
30+
id: clickerText
31+
x: 0
32+
y: 0
33+
text: clickedType + "s clicked: " + click;
34+
color: "brown"
35+
font.pixelSize: 30
36+
}
37+
}

quick_project/src/main.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <QGuiApplication>
2+
#include <QQmlApplicationEngine>
3+
4+
int main(int argc, char *argv[])
5+
{
6+
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
7+
8+
QGuiApplication app(argc, argv);
9+
10+
QQmlApplicationEngine engine;
11+
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
12+
if (engine.rootObjects().isEmpty())
13+
return -1;
14+
return app.exec();
15+
}

quick_project/src/main.qml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import QtQuick 2.0
2+
import QtQuick.Window 2.2
3+
4+
Window {
5+
id: window
6+
width: 620
7+
visible: true
8+
height: 420
9+
title: qsTr("Smiley clicker!")
10+
11+
Clicker {
12+
clickedType: "Smiley"
13+
width: 350
14+
height: 200
15+
anchors.centerIn: parent
16+
}
17+
18+
}

quick_project/src/qml.qrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<RCC>
2+
<qresource prefix="/">
3+
<file>main.qml</file>
4+
<file>Clicker.qml</file>
5+
<file>smile.png</file>
6+
</qresource>
7+
</RCC>

quick_project/src/smile.png

2.95 KB
Loading

quick_project/src/src.pro

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
QT += quick
2+
TARGET = clicker
3+
CONFIG += c++11
4+
5+
# The following define makes your compiler emit warnings if you use
6+
# any feature of Qt which as been marked deprecated (the exact warnings
7+
# depend on your compiler). Please consult the documentation of the
8+
# deprecated API in order to know how to port your code away from it.
9+
DEFINES += QT_DEPRECATED_WARNINGS
10+
11+
# You can also make your code fail to compile if you use deprecated APIs.
12+
# In order to do so, uncomment the following line.
13+
# You can also select to disable deprecated APIs only up to a certain version of Qt.
14+
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
15+
16+
SOURCES += main.cpp
17+
18+
RESOURCES += qml.qrc
19+
20+
OTHER_FILES += \
21+
Clicker.qml \
22+
main.qml \
23+
smile.png
24+
25+
# Additional import path used to resolve QML modules in Qt Creator's code model
26+
QML_IMPORT_PATH =
27+
28+
# Additional import path used to resolve QML modules just for Qt Quick Designer
29+
QML_DESIGNER_IMPORT_PATH =
30+
31+
# Default rules for deployment.
32+
qnx: target.path = /tmp/$${TARGET}/bin
33+
else: unix:!android: target.path = /opt/$${TARGET}/bin
34+
!isEmpty(target.path): INSTALLS += target
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import QtQuick 2.0
2+
import "../src" 1.00
3+
4+
Clicker {
5+
clickedType: "Click"
6+
width: 350
7+
height: 200
8+
anchors.centerIn: parent
9+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
TEMPLATE = app
2+
TARGET = tst_clicker
3+
QT += quick core testlib
4+
CONFIG += c++11 warn_on qmltestcase
5+
CONFIG -= app_bundle
6+
7+
# The following define makes your compiler emit warnings if you use
8+
# any feature of Qt which as been marked deprecated (the exact warnings
9+
# depend on your compiler). Please consult the documentation of the
10+
# deprecated API in order to know how to port your code away from it.
11+
DEFINES += QT_DEPRECATED_WARNINGS
12+
13+
# You can also make your code fail to compile if you use deprecated APIs.
14+
# In order to do so, uncomment the following line.
15+
# You can also select to disable deprecated APIs only up to a certain version of Qt.
16+
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17+
18+
SOURCES += tst_clicker.cpp
19+
20+
RESOURCES += \
21+
$$PWD/../src/qml.qrc
22+
23+
INCLUDEPATH += $$PWD/../src
24+
25+
# Additional import path used to resolve QML modules in Qt Creator's code model
26+
QML2_IMPORT_PATH = $$PWD/../src/qml.qrc
27+
28+
# Additional import path used to resolve QML modules just for Qt Quick Designer
29+
QML_DESIGNER_IMPORT_PATH =
30+
31+
# Default rules for deployment.
32+
qnx: target.path = /tmp/$${TARGET}/bin
33+
else: unix:!android: target.path = /opt/$${TARGET}/bin
34+
!isEmpty(target.path): INSTALLS += target
35+
36+
OTHER_FILES += \
37+
tst_clicker.qml \
38+
ClickerTest.qml

0 commit comments

Comments
 (0)