Hi Andre, On 13.03.2012 08:47, André Somers wrote: > Op 12-3-2012 12:33, Sven Anderson schreef: >> 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.
Thanks a lot for your answer. I'm used to getting ignored on this list most of the time. ;-) So, you mean similar to a PIMPL pattern, like having a backend QObject, that is created pairwise? Having two QObjects sounds quite heavy for a simple QML item. And also the "proxy" Object would have to instantiate the backend Object, not the other way around, since it is directly instantiated by the QML engine. So it seems a bit weird to me. > 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. Huh? I can perfectly connect to private slots from outside the class. I just tested it to be sure. Best regards, Sven _______________________________________________ Qt-qml mailing list Qt-qml@qt.nokia.com http://lists.qt.nokia.com/mailman/listinfo/qt-qml