From e9053ba3f559fcf8c4d2dd3b6f87cce0979d0244 Mon Sep 17 00:00:00 2001 From: Vladimir Minenko Date: Mon, 18 Jun 2012 12:12:21 +0200 Subject: Initial commit to add the learning-guide content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5eb8ab089b46122bc6f7042e20541bf70f173447 Reviewed-by: Topi Reiniƶ Reviewed-by: Jerome Pasion --- howtos/handle_cpp_signals/index.rst | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 howtos/handle_cpp_signals/index.rst (limited to 'howtos/handle_cpp_signals') diff --git a/howtos/handle_cpp_signals/index.rst b/howtos/handle_cpp_signals/index.rst new file mode 100644 index 0000000..d7c62bc --- /dev/null +++ b/howtos/handle_cpp_signals/index.rst @@ -0,0 +1,38 @@ +.. + --------------------------------------------------------------------------- + Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). + All rights reserved. + This work, unless otherwise expressly stated, is licensed under a + Creative Commons Attribution-ShareAlike 2.5. + The full license document is available from + http://creativecommons.org/licenses/by-sa/2.5/legalcode . + --------------------------------------------------------------------------- + +How to hadle signals from a C++ Object +====================================== + +To Handle signals from a C++ objects in your QML code, you need to add a signal handler within the object in the QML side that refers to the signal defined in the C++ code as follows: + +.. code-block:: cpp + + // file.cpp + + class MyCppObject: public QObject + { + ... + signals: + void objectSelected(const QString& message); + + } + +And here how to handle the signal above in QML: + +.. code-block:: js + + // file.qml + + MyObject { + ... + onObjectSelected : + console.log(message) + } -- cgit v1.2.3