Hi, On 10/25/2010 8:30 AM, Kai Koehne wrote: > On 10/25/2010 8:07 AM, ext Raymond de Vries wrote: >> Hi, >> >> That makes sense indeed, stupid of me. Could you point me at an example >> how to use the C++ slot from QML? I have been looking for this but I >> guess I am missing something... > There are actually multiple ways. One is to expose your slot to the QML > context, see > > http://doc.trolltech.com/4.7-snapshot/qtbinding.html#calling-c-methods-from-qml > . Ah, I understand. I had seen that page before but did not realize the use with standard widgets. > (The example shows you how to register a named object in the QML > context. If you don't like the objectName.slot() notation, you should > have a look at QDeclarativeContext::setContextObject(...)). > > Another way (and IMO better style) is to declare a signal in the QML > root element, and then connect it to the slot in the C++ part, e.g. > something like: > > x.qml: > > import QtQuick 1.0 > Rectangle { > signal startAppRequested > // ... > } > > x.cpp: > > QDeclarativeView view; > // ... > view.show(); > connect(view.rootObject(), SIGNAL(startAppRequested()), this, > SLOT(runApp()); This looks good indeed, and it makes conversion from C++ UI to QML UI much easier. This helps a lot!
Btw a little OT for here maybe but to be sure: I need to build Qt myself from git in order to use QtQuick like in your x.qml, right? regards Raymond > > Regards > > Kai > > >> thanks >> Raymond >> >> >> On 10/25/2010 5:16 AM, Gregory Schlomoff wrote: >>> As far as I know, there is no built-in support in QML for this. >>> >>> You would need to put the code in a C++ slot, and call it from QML. >>> >>> Cheers, >>> >>> Greg >>> >>> On Mon, Oct 25, 2010 at 3:51 AM, Raymond de Vries<[email protected]> >>> wrote: >>>> Hi, >>>> >>>> I would like to start an application from QML. I did not find any >>>> documentation about this so can someone please give me some advice? >>>> Starting the application from a button click would be enough. >>>> >>>> thanks a lot >>>> Raymond >>>> >>>> _______________________________________________ >>>> Qt-qml mailing list >>>> [email protected] >>>> http://lists.trolltech.com/mailman/listinfo/qt-qml >>>> >> _______________________________________________ >> Qt-qml mailing list >> [email protected] >> http://lists.trolltech.com/mailman/listinfo/qt-qml > _______________________________________________ Qt-qml mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-qml
