More QML!
This commit is contained in:
parent
b6eee3a9d9
commit
14631a937d
@ -6,13 +6,14 @@
|
||||
class CounterManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CounterManager(QObject *parent = nullptr);
|
||||
|
||||
int counter() const;
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
protected:
|
||||
private:
|
||||
int m_counter;
|
||||
|
@ -13,6 +13,7 @@ int main(int argc, char *argv[])
|
||||
QQmlApplicationEngine engine;
|
||||
auto counterManager = new CounterManager();
|
||||
engine.rootContext()->setContextProperty("_counterManager", counterManager);
|
||||
|
||||
const QUrl url(QStringLiteral("qrc:/main.qml"));
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||
|
@ -7,12 +7,12 @@ Window {
|
||||
visible: true
|
||||
title: qsTr("Hello World")
|
||||
|
||||
Text {
|
||||
text: "Counter is " + _counterManager.counter;
|
||||
anchors.centerIn: parent
|
||||
MouseArea{
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
onClicked: {_counterManager.increase()}
|
||||
|
||||
Text {
|
||||
id: text
|
||||
text: "Hello, World!"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user