B
Connections {
target: core
onParseDone:{
console.log("Test")
}
}
Size: a a a
AS
Connections {
target: core
onParseDone:{
console.log("Test")
}
}
AS
qmlRegisterType?
PM
PM
B
PM
PM
B
PM
PM
PM
PM
AS
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
class Some : public QObject
{
Q_OBJECT
public:
Some(QObject *parent = nullptr)
: QObject{parent}
{}
signals:
void done(QString msg);
public slots:
Q_INVOKABLE void process() {
emit done("finished");
}
};
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
qmlRegisterType<Some>();
Some some;
QQmlContext* context = engine.rootContext();
context->setContextProperty("some", &some);
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}
#include "main.moc"
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Button {
text: "click"
onClicked: {
some.process()
}
}
Connections {
target: some
onDone: {
console.log(msg)
}
}
}
AS