[Qt-interest] Q_PROPERTIES not visible in QMetaObject

Schimkowitsch Robert Robert.Schimkowitsch at andritz.com
Wed Oct 5 10:17:15 CEST 2011


A stale library / linking problem seesm to be the issue here.

I tried with a small test project, first within the same project, then with including a library, and everything worked.

After a complete clean and rebuild, it worked for my production code, too.

Thanks!

Robert Schimkowitsch


-----Original Message-----
From: Girish Ramakrishnan [mailto:girish at forwardbias.in] 
Sent: Wednesday, October 05, 2011 8:15 AM
To: Schimkowitsch Robert
Cc: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Q_PROPERTIES not visible in QMetaObject

Hi,

On Tue, Oct 4, 2011 at 9:44 PM, Schimkowitsch Robert
<Robert.Schimkowitsch at andritz.com> wrote:
> I have declared a couple of properties in an QObject-subclass, but they do
> not become visible when iterating through all QMetaObject's properties.
>
> I have the class:
>
> class CPel_PictureElement : public CPel_ContainerElement
> {
>     Q_OBJECT
>     Q_INTERFACES(IPel_Element)
>
>     Q_PROPERTY(QString PictureName READ pictureName WRITE setPictureName)
>     Q_PROPERTY(QString PictureAuthor READ pictureAuthor WRITE
> setPictureAuthor)
>
> // Constructors, Methods and Members
> }
>
> Q_DECLARE_METATYPE(CPel_PictureElement*)
>
> CPel_ContainerElement, a QGraphicsWidget, and thereby a QObject subclass.
> (It is also a subclass of a registered interface called IPel_Element)).
>
> The class is compiled within a static library (.a-file using MinGW), and
> used in an executable.
>
> There I attempt to read the property information this way:
>
>                 CPel_PictureElement* pic = new CPel_PictureElement();
>
>                 for ( int i = 0; i < pic->metaObject()->propertyCount();
> ++i)
>                 {
>                     qDebug() << pic->metaObject()->property(i).name();
>                 }
>
> I only get the properties up to QGraphicsWidget, not the two properties I
> have defined.
>
> I have also tried manually calling
> qRegisterMetaType<CPel_PictureElement*>();
> - doesn't change anything.
>
> Any ideas what might be wrong here?
>

The above code should work. Maybe something to do with your code
linking to stale objects/libraries? I have often seen .pro files setup
in such a way that even though the static library is built, their
executable is NOT relinked. Which, of course, means that the app is
still using some old code.

Also, your problem of missing properties has nothing to do with
qRegisterMetaType.

Girish

#####################################################################################
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 beschränkter 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