You are not logged in.

samdutton

Intermediate

  • "samdutton" is male
  • "samdutton" started this thread

Posts: 160

Location: Australian in London

Occupation: C++ and Web developer

  • Send private message

1

Tuesday, April 6th 2004, 3:09pm

Can subclasses inherit properties?

I have a ListViewItem class which inherits from both QListViewItem and a class of my own named Story.

I currently use metaobject properties to get and set values for Story objects. Can I use this to get and set properties for ListViewItem objects? I thought that the metaobject properties would be inherited by ListViewItem, but it doesn't seem to be working. I've tried adding Q_PROPERTY declarations to the ListViewItem class, but that doesn't help.

Any suggestions gratefully received.

Sam Dutton

br06

Trainee

  • "br06" is male

Posts: 121

Location: Germany

Occupation: surveying engineer

  • Send private message

2

Tuesday, April 6th 2004, 8:12pm

RE: Can subclasses inherit properties?

Hi,

Your class has to inherit from QObject or a subclass for using properties.

Christian

samdutton

Intermediate

  • "samdutton" is male
  • "samdutton" started this thread

Posts: 160

Location: Australian in London

Occupation: C++ and Web developer

  • Send private message

3

Wednesday, April 7th 2004, 10:41am

RE: Can subclasses inherit properties?

Christian --- thanks for your reply.

>> Your class has to inherit from QObject or a subclass for using properties <<

It does: my ListViewItem class inherits from both QListViewItem and a class of my own named Story.

Story inherits from QObject and uses properties.

This works fine -- but not for ListViewItem. When called on a ListViewItem object, for example, metaObject()->findProperty(), for example, never finds anything.

Mysteriously, I can set property values for a ListViewItem using a set method and then get the property using property().

Sam

dimitri

Professional

  • "dimitri" is male

Posts: 1,311

Occupation: Engineer

  • Send private message

4

Thursday, April 8th 2004, 8:08am

RE: Can subclasses inherit properties?

Make sure you inherit Story first:
http://doc.trolltech.com/3.3/moc.html#5-1