On 10/25/2010 9:40 AM, ext Raymond de Vries wrote: > 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?
Right. The QtQuick 1.0 namespace will be introduced in 4.7.1 : http://www.mail-archive.com/[email protected]/msg01040.html Just keep "import Qt 4.7" if you develop with 4.7.0. Regards Kai -- 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
