-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
#include <QObject> | ||
#include <QQmlEngine> | ||
|
||
class QmlCppExposed : public QObject | ||
{ | ||
Q_OBJECT | ||
QML_ELEMENT | ||
Q_PROPERTY(int foo READ getFoo WRITE setFoo NOTIFY fooChanged) | ||
|
||
public: | ||
inline int getFoo() const { return m_foo; } | ||
inline void setFoo(int value) { | ||
if (value == m_foo) | ||
return; | ||
m_foo = value; | ||
emit fooChanged(); | ||
} | ||
|
||
signals: | ||
void fooChanged(); | ||
|
||
private: | ||
int m_foo = 42; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
#include <QObject> | ||
#include <QQmlEngine> | ||
|
||
class QmlCppOtherExposed : public QObject | ||
{ | ||
Q_OBJECT | ||
QML_ELEMENT | ||
Q_PROPERTY(int foo READ getFoo WRITE setFoo NOTIFY fooChanged) | ||
|
||
public: | ||
inline int getFoo() const { return m_foo; } | ||
inline void setFoo(int value) { | ||
if (value == m_foo) | ||
return; | ||
m_foo = value; | ||
emit fooChanged(); | ||
} | ||
|
||
signals: | ||
void fooChanged(); | ||
|
||
private: | ||
int m_foo = 42; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <QGuiApplication> | ||
#include <QQmlApplicationEngine> | ||
|
||
int main(int argCount, char* argVector[]) | ||
{ | ||
QGuiApplication app(argCount, argVector); | ||
QQmlApplicationEngine engine; | ||
engine.load("qrc:///qt/qml/Foo/Bar/QmlStuff.qml"); | ||
app.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import QtQuick 2.0 | ||
|
||
Item { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pragma Singleton | ||
import QtQuick | ||
|
||
QtObject { | ||
property int myprop: 51 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import QtQuick 2.0 | ||
import Foo.Bar 1.0 | ||
|
||
Window { | ||
width: 640 | ||
height: 200 | ||
visible: true | ||
title: qsTr("Sample") | ||
|
||
QmlCppExposed { | ||
id: cppExposed | ||
} | ||
Text { | ||
id: cppExposedTxt | ||
text: "value from Cpp exposed " + cppExposed.foo + " (should be 42)" | ||
} | ||
Text { | ||
id: singletonTxt | ||
anchors.top: cppExposedTxt.bottom | ||
text: "value from Singleton exposed " + QmlSingleton.myprop + " (should be 51)" | ||
} | ||
QmlOtherStuff { | ||
anchors.top: singletonTxt.bottom | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters