November 6, 2011

Iakov Minochkin Iakov Minochkin
Lab Rat
4 posts

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

November 6, 2011

Gerolf Gerolf
Robot Herder
3252 posts

If you want to extract code of Qt, I’m afraid you must carefully read the code an check it your self.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 6, 2011

Iakov Minochkin Iakov Minochkin
Lab Rat
4 posts

I only want to bind with QtCore library and to use at least moc and resource compilers.

November 6, 2011

Lukas Geyer Lukas Geyer
Lab Rat
2074 posts

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.

November 6, 2011

Iakov Minochkin Iakov Minochkin
Lab Rat
4 posts

To spoil your first question: DirectConnection doesn’t, QueuedConneciton does.

thank you, logic!)

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?

November 7, 2011

Lukas Geyer Lukas Geyer
Lab Rat
2074 posts

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].

November 7, 2011

Gerolf Gerolf
Robot Herder
3252 posts

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.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 7, 2011

Iakov Minochkin Iakov Minochkin
Lab Rat
4 posts

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().

November 7, 2011

Andre Andre
Robot Herder
6393 posts

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.

 
  ‹‹ [solved] QNetworkAccessManager uploading files      Setting volume in Phonon ››

You must log in to post a reply. Not a member yet? Register here!