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 . (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()); 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 -- Kai Koehne Software Engineer Nokia, Qt Development Frameworks Nokia gate5 GmbH Firmensitz: Invalidenstr. 117, 10115 Berlin, Germany Registergericht: Amtsgericht Charlottenburg, Berlin: HRB 106443 B Umsatzsteueridentifikationsnummer: DE 812 845 193 Geschäftsführer: Dr. Michael Halbherr, Karim Tähtivuori _______________________________________________ Qt-qml mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-qml
