Hi Uli,

thank you for sharing that document, that's indeed very helpful.
Following its examples, I was able to set up my singleton such that both
runtimes (C++, QML) would share the same instance.
Doing that I bumped into what I would consider a bug, probably in the MOC
infrastructure:
The example I used was

```
struct SingletonForeign
{
  Q_GADGET
  QML_FOREIGN(MySingleton)
  QML_SINGLETON
  QML_NAMED_ELEMENT(MySingleton)
public:
  static MySingleton *create(QQmlEngine *, QJSEngine *engine);
};
```

which works fine. Then I wanted to clean the code up a little more, and
removed the "public:", given that the above is a `struct`, so everything in
it is public anyhow. And that's where it stopped working !
I assume this is because the MOC isn't really aware of C++ semantics, and
for some reason really requires the "public" specifier to be there. Why
isn't the MOC using an actual compiler frontend to analyse these
declarations ?

Thanks,

-- 

      ...ich hab' noch einen Koffer in Berlin...
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to