[Qt-interest] QMetaType::type succeeds or fails seemingly
Schimkowitsch Robert
Robert.Schimkowitsch at andritz.com
Fri Sep 30 08:40:20 CEST 2011
I can't use qRegisterMetaType<MyType>(), because I don't know the type
at compile time.
The type is defined inside a library, and I only get it by iterating
through the properties of a QObject-based class defined within that
library.
My test code knew the type, but that was just test code.
In my real app, I try to set the properties of an unknown QObject-based
class from an input XML file.
I iterate through all properties. If they are an enumeration type, I get
the QMetaEnum information. If the string from the XML file matches any
of the enum keys, I assign the enum that value.
What would really help me would be some method I could call on the
QObject that would ensure all DECLARE_METATYPE enums related to that
object are resolved.
Kind Regards
Robert Schimkowitsch
-----Original Message-----
From: qt-interest-bounces+robert.schimkowitsch=andritz.com at qt.nokia.com
[mailto:qt-interest-bounces+robert.schimkowitsch=andritz.com at qt.nokia.co
m] On Behalf Of Thiago Macieira
Sent: Wednesday, September 28, 2011 10:31 AM
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] QMetaType::type succeeds or fails seemingly
On Wednesday, 28 de September de 2011 10:15:34 Stefan Majewsky wrote:
> On Mon, Sep 26, 2011 at 4:50 PM, Schimkowitsch Robert
>
> <Robert.Schimkowitsch at andritz.com> wrote:
> > Which brings up the question: When does Q_DECLARE_METATYPE run, and
how
> > do I make it run?
>
> Looking at the definition of Q_DECLARE_METATYPE, in
> include/QtCore/qmetatype.h, you should be able to "make it run" by
>
> (void) QMetaType<MyType>::qt_metatype_id();
>
> before the QMetaType::type() call. I don't know about the ABI
> stability policy for this macro, but I think this should be
> binary-compatible until at least Qt 5.
You can use the documented way:
qRegisterMetaType<MyType>();
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
#####################################################################################
This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.
Thank You.
ANDRITZ HYDRO GmbH
Rechtsform/ Legal form: Gesellschaft mit beschrankter Haftung / Corporation
Firmensitz/ Registered seat: Wien
Firmenbuchgericht/ Court of registry: Handelsgericht Wien
Firmenbuchnummer/ Company registration: FN 61833 g
DVR: 0605077
UID-Nr.: ATU14756806
#####################################################################################
More information about the Qt-interest-old
mailing list