Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Inheritance issue not direct base of.
Forum Updated to NodeBB v4.3 + New Features

Inheritance issue not direct base of.

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rocketchicken
    wrote on last edited by
    #1

    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]]

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rocketchicken
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

          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).

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rocketchicken
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rocketchicken
                wrote on last edited by
                #7

                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!

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  rocketchicken
                  wrote on last edited by
                  #8

                  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!

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved