Turn CppUtils into a Singleton
This commit is contained in:
parent
e7caa0b8ef
commit
f34d2a1c6d
|
@ -2,6 +2,7 @@
|
|||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import CppUtils 0.1
|
||||
import "../../../Base"
|
||||
|
||||
HColumnLayout {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import CppUtils 0.1
|
||||
import "../../../Base"
|
||||
|
||||
HTile {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import QtQuick 2.12
|
||||
import io.thp.pyotherside 1.5
|
||||
import CppUtils 0.1
|
||||
|
||||
Python {
|
||||
id: py
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import QtQuick 2.12
|
||||
import CppUtils 0.1
|
||||
|
||||
QtObject {
|
||||
function makeObject(urlComponent, parent=null, properties={},
|
||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -39,9 +39,19 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// Add our custom non-visual `QObject `s as properties.
|
||||
// Their attributes and methods will be accessing like normal QML objects.
|
||||
objectContext->setContextProperty("CppUtils", new Utils());
|
||||
/* objectContext->setContextProperty("CppUtils", new Utils()); */
|
||||
objectContext->setContextProperty("Clipboard", new Clipboard());
|
||||
|
||||
|
||||
qmlRegisterSingletonType<Utils>(
|
||||
"CppUtils", 0, 1, "CppUtils",
|
||||
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
|
||||
Q_UNUSED(engine)
|
||||
Q_UNUSED(scriptEngine)
|
||||
return new Utils();
|
||||
}
|
||||
);
|
||||
|
||||
// Register our custom visual items that will be importable from QML,
|
||||
// e.g. `import RadialBar 1.0`
|
||||
qmlRegisterType<RadialBar>("RadialBar", 1, 0, "RadialBar");
|
||||
|
|
Loading…
Reference in New Issue
Block a user