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.
8 replies
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.
The usual way is filing a suggestion to JIRA [bugreports.qt.nokia.com] or compiling such a list on your own and submitting it to the Qt project [qt-project.org].
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.
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.
You must log in to post a reply. Not a member yet? Register here!



