Reusing QtCore module in any C++ project
I'm very interested in reusing metaobject system and general functionality, but don't know exactly:
- Has QMetaObject::invokeMethod() dependency on event loop?
- Can I load plugins without QCoreApplication instance?
Some list of using restrictions of this module in non-qt application/in non-main thread would be greatly appreciated.
If you want to extract code of Qt, I'm afraid you must carefully read the code an check it your self.
I only want to bind with QtCore library and to use at least moc and resource compilers.
The easiest way to find out such things is usually a try. To spoil your first question: DirectConnection doesn't, QueuedConneciton does. As to your second question: if you do something that requires a QCoreApplication instance there is usually a warning issued or your application aborts immediately.
bq. To spoil your first question: DirectConnection doesn’t, QueuedConneciton does.
thank you, logic!)
bq. The easiest way to find out such things is usually a try
yes of course, but if I want suggest to Nokia to publish some documentation about this problem what should I do?
If you use QMetaObject qithout QObjects, you could get some compiler problems. In the interface of QMetaObject, you can see:
bool invoke(QObject *object, ...
And all methods, that are used for signal/slot handling use QObject pointers.
bq. If you use QMetaObject qithout QObjects, you could get some compiler problems. In the interface of QMetaObject, you can see:
bool invoke(QObject *object, …
It's clear that not possible to use metaobject system without inheritance from QObject, Q_OBJECT macro and moc compiler.
bq. And all methods, that are used for signal/slot handling use QObject pointers.
Signal/slot handling can't be done without event loop as I understand and that's why I can't use QObject::connect() without QCoreApplication::exec().
I think signal/slot handling can be done without having an eventloop, but only if you use direct connections only. By default, signal/slot connections are direct, unless the thread the emit happens in is different from the thread in which the object lives. In that case, a Queued connection is used, which does need an eventloop. Lukas already explained that earlier in this topic.
QObject is quite fundamental to using any of the nice Qt features, so I see little chance of getting around it. However, I think quite a bit can be done without using a QCoreApplication, though I think GUI stuff and sockets and the likes of those are off.