File tree Expand file tree Collapse file tree 12 files changed +232
-0
lines changed Expand file tree Collapse file tree 12 files changed +232
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ qrc_*.cpp
1212ui_ * .h
1313Makefile *
1414* build- *
15+ * .qmlc
1516
1617# QtCreator
1718
Original file line number Diff line number Diff line change 1+ TEMPLATE = subdirs
2+ SUBDIRS += \
3+ src \
4+ test_runner
5+
6+ test_runner.depends = src
Original file line number Diff line number Diff line change 1+ import QtQuick 2.9
2+ import QtQuick.Dialogs 1.1
3+ import QtQuick.Controls 1.0
4+
5+ Item {
6+ id: cookieClicker
7+ anchors .fill : parent
8+
9+ // Write correct properties and aliases here
10+ // BEGIN SOLUTION
11+ property int click: 0
12+ property string welcome : " Generic welcome!"
13+ property alias status: cookieText
14+ property string clickedType : " Cookie"
15+ // END SOLUTION
16+
17+ Image {
18+ id: image
19+ anchors .fill : parent
20+ fillMode: Image .PreserveAspectFit
21+ source: " qrc:/cookie.jpg"
22+
23+ // Write something clickable here!
24+ // BEGIN SOLUTION
25+ MouseArea {
26+ anchors .fill : parent
27+ onClicked: {
28+ click++ ;
29+ cookieText .text = clickedType + " s clicked: " + click;
30+ }
31+ }
32+ // END SOLUTION
33+ }
34+
35+ Text {
36+ anchors .horizontalCenter : parent .horizontalCenter
37+ id: cookieText
38+ x: 0
39+ y: 0
40+ text: welcome
41+ color: " brown"
42+ font .pixelSize : 30
43+ }
44+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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 (" Hello Cookie" )
10+
11+ CookieClicker {
12+ welcome: " Cookie clicker!"
13+ clickedType: " Chocolate cookie"
14+ width: 350
15+ height: 200
16+ anchors .centerIn : parent
17+ }
18+
19+ }
Original file line number Diff line number Diff line change 1+ <RCC>
2+ <qresource prefix="/">
3+ <file>main.qml</file>
4+ <file>CookieClicker.qml</file>
5+ <file>cookie.jpg</file>
6+ </qresource>
7+ </RCC>
Original file line number Diff line number Diff line change 1+ QT += quick
2+ TARGET = main
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+ # Additional import path used to resolve QML modules in Qt Creator's code model
21+ QML_IMPORT_PATH =
22+
23+ # Additional import path used to resolve QML modules just for Qt Quick Designer
24+ QML_DESIGNER_IMPORT_PATH =
25+
26+ # Default rules for deployment.
27+ qnx: target.path = /tmp/ $${TARGET }/bin
28+ else: unix :!android: target.path = /opt/ $${TARGET }/bin
29+ !isEmpty (target.path ): INSTALLS += target
Original file line number Diff line number Diff line change 1+ import QtQuick 2.0
2+ import "../src/" 1.00
3+
4+ CookieClicker {
5+ welcome: " Cookie clicker!"
6+ clickedType: " Chocolate cookie"
7+ width: 350
8+ height: 200
9+ anchors .centerIn : parent
10+ }
Original file line number Diff line number Diff line change 1+ TEMPLATE = app
2+ TARGET = tst_cookieclicker
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_cookieclicker.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_cookieclicker.qml \
38+ CookieClickerTest.qml
You can’t perform that action at this time.
0 commit comments