[odb-users] Qt and classes derived from QObject

Diego Fernando lordvampyre at gmail.com
Tue Feb 3 07:26:28 EST 2015


Hi Boris,

Employee and Person class

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.

        //

        v = ptr_traits::pointer_type (

          static_cast<pgsql::database*> (db)->load<

            obj_traits::object_type > (id));

      }


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.


Thank you


More information about the odb-users mailing list