[odb-users] Qt and classes derived from QObject

Diego Fernando lordvampyre at gmail.com
Tue Feb 3 14:57:58 EST 2015


Thank you I change and now it's working.

2015-02-03 13:14 GMT-02:00 Boris Kolpackov <boris at codesynthesis.com>:

> Hi Diego,
>
> Diego Fernando <lordvampyre at gmail.com> writes:
>
> > class Person : public QObject
> >
> > class Employee : public OQbject
> > {
> >   Person *person;
> > }
> >
> > It's compile output:
> > error: invalid cast from type 'odb::object_traits<Person>::pointer_type
> > {aka QSharedPointer<Person>}' to type
> > 'odb::pointer_traits<Person*>::pointer_type {aka Person*}'
> >              obj_traits::object_type > (id));
> >
> > Show this line on code
> >
> >         // If a compiler error points to the line below, then
> >         // it most likely means that a pointer used in a member
> >         // cannot be initialized from an object pointer.
> >         //
> >
> >
> >       }
> >
> > I am using Qt and QML and exists some way to make this works without
> > duplicate the code where one class is derived from QObject and another
> > no.
>
> This has nothing to do with deriving (or not) from QObject. You are
> using the Qt profile which makes QSharedPointer the default object
> pointer. This is probably the right choice for most situations,
> including yours. So simply change:
>
> Person *person;
>
> To:
>
> QSharedPointer<Person> person;
>
> Boris
>
>


More information about the odb-users mailing list