qt - qt5 qml c++ interaction -
http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html#connecting-to-qml-signals
i've read of article, , seem understand except part in c++. qobject::connect(item, signal(qmlsignal(qstring)), &myclass, slot(cppslot(qstring)));
it clear item
, signal
, myclass
, slot
, cppslot
, qstring
come from, qmlsignal
come from? of course comes .qml file, how compiler find out if it's loaded via runtime?
it clear item, signal, myclass, slot, cppslot , qstring come from, qmlsignal come from? of course comes .qml file, how compiler find out if it's loaded via runtime?
qmlsignal emitted qml code , caught on c++ side noted. , compiler knows nothing of happening @ run time except c++ types code deals with.
the root qml item reflected qobject has nested list of signals , slots pure c++ qobject. every signal , slot has test string signature , slots have mapping class member.
qquickview view(qurl::fromlocalfile("myitem.qml")); qobject *item = view.rootobject(); // qobject qml root myclass myclass; qobject::connect(item, signal(qmlsignal(qstring)), // find "qmlsignal(qstring)" in list of signals of 'item' &myclass, slot(cppslot(qstring))); // connect signal entry found cppslot(qstring) entry of myclass object
for better understanding of signal-slot internals there article: http://woboq.com/blog/how-qt-signals-slots-work.html
the above of course string-based connections: http://doc.qt.io/qt-5/signalsandslots-syntaxes.html
not many articles on qml signal/slot bindings some: http://www.kdab.com/qml-engine-internals-part-2-bindings/
Comments
Post a Comment