Op 12-3-2012 12:33, Sven Anderson schreef: > Hi all, > > if I implement QML types in C++, all slots are invokable from QML. > Usually I don't want that, because the slots are for C++ internal > communication. I found out (see older mail), that declaring the slots as > private makes them inaccessible from QML, but I can still connect to > them in the C++ world. My question is: can I rely on this, or is this an > unsupported feature? And a second question is: are there other good ways > of hiding slots from QML? > > Thanks and best regards > You could define a proxy QObject who's only purpose is to expose the API you want to expose to QML, and nothing more than that. All it would do would be forwarding the needed signals and slots to the real C++ implementation, that can be as complicated as you want as you don't expose it outside of the C++ context. This is also basically how you expose an interface for scripting, or for DBus.
I would not recommend making slots private just to hide them from QML. While you can still connect to those slots from within that class, you can no longer connect to it from outside the class itself. That may hurt the API of that class. André _______________________________________________ Qt-qml mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-qml
