Re: [Interest] How to create QObject-derived class instance from class name

2016-03-02 Thread Sina Dogru
> > Ah you mean by "knowing types at compile time" is actually defined > types, so you actually defining classes at run-time? > Sina, > No, I didn't mean that. You can't define classes at runtime as C++ is not > a dynamic language. > Yeah, but sometimes qt makes me confuse, reflection was also not

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-02 Thread Nye
> You can either use QMetaType for that or your own registration/factory. Thiago, Yes, that's exactly true. I just decided to use QMetaType, as Qt already provides the registration/creation infrastructure, instead of pushing a factory object to the library that will create the instances (or using m

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-02 Thread Thiago Macieira
On quarta-feira, 2 de março de 2016 13:04:35 PST Nye wrote: > I just meant that in my case the classes are defined in the user > application, so the library has no notion whatsoever what classes it has > available to create instances from and it depends on the meta-type system > exclusively for tha

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-02 Thread Sina Dogru
Ah you mean by "knowing types at compile time" is actually defined types, so you actually defining classes at run-time? 2016-03-02 13:04 GMT+02:00 Nye : > I just meant that in my case the classes are defined in the user > application, so the library has no notion whatsoever what classes it has >

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-02 Thread Nye
I just meant that in my case the classes are defined in the user application, so the library has no notion whatsoever what classes it has available to create instances from and it depends on the meta-type system exclusively for that (while still handling the serialization/deserialization of said in

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-02 Thread André Somers
Op 02/03/2016 om 11:51 schreef Sina Dogru: >For now there is a design choice which I feel weak myself, to do factory or to use QMetaType for creating instances. Depends on the use case I suppose. If you know the types at compile time, as is usually the case I'd go with the sim

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-02 Thread Sina Dogru
> > > For now there is a design choice which I feel weak myself, to do > factory or to use QMetaType for creating instances. > > Depends on the use case I suppose. If you know the types at compile time, > as is usually the case I'd go with the simple solution to make a factory. I > recently, howeve

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-02 Thread Nye
> For now there is a design choice which I feel weak myself, to do factory or to use QMetaType for creating instances. Depends on the use case I suppose. If you know the types at compile time, as is usually the case I'd go with the simple solution to make a factory. I recently, however, had a case

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-01 Thread Sina Dogru
I thank you for your answers and solutions. Before I wrote, I tried to use QMetaType::create function to instantiate an instance but since QObject have deleted copy constructor and copy assignment operator, I have ended up using QObject pointer with QMetaType.. And when I see that QMetaType::creat

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-01 Thread André Somers
Op 01/03/2016 om 17:21 schreef Thiago Macieira: On terça-feira, 1 de março de 2016 17:06:49 PST André Somers wrote: The meta *object* system has no registration. The meta *type* system requires that the registered type be default- constructible and copyable, but QObject is not copyable. There

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-01 Thread Prashanth Udupa
But we can do this though -- #include #include #include class Object1 : public QObject { Q_OBJECT public: Q_INVOKABLE Object1(QObject *parent=0) : QObject(parent) { } ~Object1() { } }; class Object2 : public QObject { Q_OBJECT public: Q_INVOKABLE Object2(QObject *parent=

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-01 Thread Thiago Macieira
On terça-feira, 1 de março de 2016 17:06:49 PST André Somers wrote: > > The meta *object* system has no registration. > > > > The meta *type* system requires that the registered type be default- > > constructible and copyable, but QObject is not copyable. Therefore, > > QObject- derived classes ca

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-01 Thread André Somers
Op 01/03/2016 om 16:30 schreef Thiago Macieira: On terça-feira, 1 de março de 2016 13:59:07 PST André Somers wrote: I think you did not get the point about QMetaType and QMetaObject. They _can_ be used together: I don't think that they can. 1) mark the constructors in the classes you want t

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-01 Thread Thiago Macieira
On terça-feira, 1 de março de 2016 13:59:07 PST André Somers wrote: > I think you did not get the point about QMetaType and QMetaObject. They > _can_ be used together: I don't think that they can. > 1) mark the constructors in the classes you want to be able to construct > from your file as Q_INV

Re: [Interest] How to create QObject-derived class instance from class name

2016-03-01 Thread André Somers
Op 01/03/2016 om 13:40 schreef Sina Dogru: Hello everyone, Basically, I have a file which I do save some QObject-derived instances states. I do save them to be able to use those to recover the states of those QObject-derived instances. I do also save the QMetaObject::className() in the fil

[Interest] How to create QObject-derived class instance from class name

2016-03-01 Thread Sina Dogru
Hello everyone, Basically, I have a file which I do save some QObject-derived instances states. I do save them to be able to use those to recover the states of those QObject-derived instances. I do also save the QMetaObject::className() in the file. And at the run-time, I would like to dynamicall