Why can't I set the parent of a QObject in a class whose QObject is only an indirect base?

I have a class BatchItemthat inherits QObject, plus several classes that inherit from BatchItem:

#ifndef BATCHITEM_H
#define BATCHITEM_H

#include <QObject>

class BatchItem : public QObject
{
    Q_OBJECT
public:
    virtual void start() = 0;
    virtual void stop() = 0;

signals:
    /* ... some signals ... */

};

#endif // BATCHITEM_H

Example class inheriting from BatchItem:

#ifndef VIDEOBATCHITEM_H
#define VIDEOBATCHITEM_H

#include "batchprocessing/batchitem.h"

#include <QtCore/QObject>

class VideoBatchItem : public BatchItem
{
    Q_OBJECT
public:
    explicit VideoBatchItem(/* ... */, QObject *parent = 0);

    void start();
    void stop();

private:
    /* ... some private member variables ... */
};

#endif // VIDEOBATCHITEM_H

And this is the corresponding .cpp:

#include "videobatchitem.h"

VideoBatchItem::VideoBatchItem(/* ... */,
                               QObject *parent) :
    /* ... */,
    QObject(parent)
{
    /* ... */
}

/* ... */

But when I try to compile, I get the following error:

error: type ‘QObject’ is not a direct base of ‘VideoBatchItem’

, , , QObject VideoBatchItem. ? , . QAbstractScrollArea, QFrame, , , QWidget? QWidget , QAbstractScrollArea QWidget. , , .cpp .

QObject, - Qt ?

+5
1

QObject. , QObject ( QObject *). BatchItem() setParent (parent) BatchItem (QObject *).

+4

All Articles