0

I want to use my objects as QVariants and for queued connections. Therefore I want to use Q_DECLARE_METATYPE(My_Item) and from the documentation I learned that I need a public copy constructor. I tried to write one, but I failed. Than I did read this copy constructor of derived QT class and the answer by BЈовић. From there I understand that what I intended to do is not going to work. What do I have to do make my objects useable for the Metatypesystem?

My_Item is based on My_Super_Item, which look like this:

class My_Item: public My_Super_Item { Q_OBJECT Q_INTERFACES(QGraphicsItem) public: explicit My_Item(Application *a, QString astring); ... } 

and

class My_Super_Item : public QObject, public virtual QGraphicsItem { Q_OBJECT Q_INTERFACES(QGraphicsItem) public: My_Super_Item(My_Application *a, QString astring); ... } 
13
  • What is your goal here? Commented Nov 14, 2016 at 7:54
  • @thuga : updated the question, in general I want to learn how to use these features Commented Nov 14, 2016 at 22:03
  • You cannot copy QObjects. Why do you want to put them in QVariant anyway? You don't need Q_DECLARE_METATYPE for queued connections. Commented Nov 15, 2016 at 7:12
  • I understood that I have to use Q_DECLARE_METATYPE for own objects when using signals between threads. And that QVariant is a method for putting different objects into a list together. Commented Nov 15, 2016 at 15:44
  • What other object types you have in this list? For queued connections you need qRegisterMetaType. Commented Nov 16, 2016 at 12:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.