Inheritance issue not direct base of.



  • I have been looking through the documentation of Qt and have not been able to find information about direct inheritance of a Qt Class, I have found information about multiple inheritance.

    Perhaps someone can clear this up.

    In the documentation
    QObject-->QMediaObject-->QCamera-->MyOwnCamera

    That is I am trying to inherit the QCamera.
    @
    class MyOwnCamera :public QCamera
    {
    Q_OBJECT

    Q_INVOKABLE void StartCamera()
    {
    qDebug() << "Camera start has been signaled";
    }

    public:
    explicit MyOwnCamera(QObject* parent = 0);

    signals:

    public slots:

    void CameraActivation()
    {
    qDebug() << "Camera has been signaled";
    }

    };

    MyOwnCamera::MyOwnCamera(QObject* parent) :
    QObject(parent)
    {

    }
    @

    Resulting in QObject is not a direct base of MyOwnCamera, which is true. I have found this
    but according to this I would have to modify the QCamera ?
    http://qt-project.org/forums/viewthread/7062

    Is there anyway around this ? I figure I am probably supposed to use multiple inheritance
    or object composition I guess?

    Thanks.

    [[added code markup, Tobias]]


  • Moderators

    Try to replace QObject with QCamera in line25.

    You might need to pass additional parameters to QCamera (I never used this class so far) though. Check the documentation of this class if that is the case.



  • QCamera(QObject * parent = 0)
    QCamera(const QByteArray & device, QObject * parent = 0)

    I don't think I would need to pass the QByteArray yet.

    Undefined symbols for architecture x86_64:
    "QMediaObject::bind(QObject*)", referenced from:
    vtable for BalenceCamerain moc_balencecamera.o
    "QMediaObject::unbind(QObject*)", referenced from:
    vtable for BalenceCamerain moc_balencecamera.o
    "QCamera::qt_metacall(QMetaObject::Call, int, void**)", referenced from:
    BalenceCamera::qt_metacall(QMetaObject::Call, int, void**)in moc_balencecamera.o
    "QCamera::qt_metacast(char const*)", referenced from:
    BalenceCamera::qt_metacast(char const*)in moc_balencecamera.o
    "QCamera::staticMetaObject", referenced from:
    BalenceCamera::staticMetaObject in moc_balencecamera.o
    "QCamera::QCamera(QObject*)", referenced from:
    BalenceCamera::BalenceCamera(QObject*)in balencecamera.o
    BalenceCamera::BalenceCamera(QObject*)in balencecamera.o
    "QCamera::~QCamera()", referenced from:
    BalenceCamera::~BalenceCamera()in moc_balencecamera.o
    BalenceCamera::~BalenceCamera()in moc_balencecamera.o
    "QMediaObject::isAvailable() const", referenced from:
    vtable for BalenceCamerain moc_balencecamera.o
    "QMediaObject::service() const", referenced from:
    vtable for BalenceCamerain moc_balencecamera.o
    "QCamera::availability() const", referenced from:
    vtable for BalenceCamerain moc_balencecamera.o
    "typeinfo for QCamera", referenced from:
    typeinfo for BalenceCamerain moc_balencecamera.o

    I changed the name of the object to BalenceCamera btw,
    I tried what you suggested above and got linking errors oddly.


  • Moderators

    If you do not need it, then leave it out, there is a constructor that only takes a QObject, so you should be fine using that.

    Try rerunning qmake. Vtable issues often point to moc information being missing (no Q_OBJECT macro) or outdated (e.g. due to the class being renamed and make/qmake missing that fact).



  • Yeah I tried it again cleaned my project compiled, same issue, cleaned all tried again same issue. Could it be that the QCamera is not constructing the QMediaObject and that is not constructing the QObject? Not quite sure how this works in alot of examples I have seen people usually just compose the objects in a class that inherits from QObject.


  • Moderators

    You are on macosx? Do you have a 64bit library containing QMediaObject? Check it to make sure;)



  • Yeah it looks like that library was not installed correctly in the framework, it appears to be that way for both my android and my bb10 installation. I will compile all the sources to the latest version and try again thanks for the help!



  • Okay I figured out the linking issue, All of what you said above works well. The issue was in my qt.pro file I forgot to include
    QT += multimedia multimediawidgets

    Everything links fine now thanks again!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.