Missing something when trying to subclass DzExporter - what is it?

Hello,

I am trying to create an exporter plugin by subclassing DzExporter but am receiving the error C2259 'cannot instantiate abstract class' when I try to compile.

I have overridden all the pure virtual methods that are defined in DzExporter and cannot see what else to do as the compiler provides no more information.

If I define a class

class MyQObject : public QObject {
 Q_OBJECT
public:
 MyQObject() {}
};

and give this to the DZ_PLUGIN_CLASS_GUID() macro, the project builds fine, so the issue must be somewhere in the hierarchy of classes that my exporter sits in.

Here is my exporter

class MyDazExporter : public DzExporter {
 Q_OBJECT
public:

 /** Constructor **/
 MyDazExporter() : DzExporter(QString("ext")) { }

public slots:

 virtual QString getDescription() const { return QString("hello"); };
 virtual bool isFileExporter() const { return true; };

protected:

 virtual DzError write( const QString &filename;, const DzFileIOSettings *options ) const { return 0; };
};

The DzExporter is defined


class DZ_EXPORT DzExporter : public DzFileIO {
 Q_OBJECT
public:

 DzExporter( const QString &extension; );
 virtual ~DzExporter();

public slots:
 DzError writeFile( const QString &filename; );
 DzError writeFile( const QString &filename;, const DzFileIOSettings *options );

 QString   getExtension() const { return m_extension; }
 virtual QString getDescription() const = 0;
 virtual bool isFileExporter() const = 0;

protected:
 virtual DzError write( const QString &filename;, const DzFileIOSettings *options ) = 0;

private:
 QString m_extension;
};

If I copy my class into one of the example projects I get the same result.

What else do I have to do?

Comments

  • msorrelsmsorrels Posts: 44
    edited July 2013

    When I try compiling your code I get the following:
    ..\recentfilesaction.cpp(53) : error C2259: 'MyDazExporter' : cannot instantiate abstract class
    due to following members:
    'void DzFileIO::getDefaultOptions(DzFileIOSettings *) const' : is abstract
    e:\work\dazstudio\sdk4.5\include\dzfileio.h(81) : see declaration of 'DzFileIO::getDefaultOptions'
    'DzError DzExporter::write(const QString &,const DzFileIOSettings *)' : is abstract
    E:\Work\DazStudio\sdk4.5\include\dzexporter.h(76) : see declaration of 'DzExporter::write'

    Which means you have to also provide an implementation of getDefaultOptions

    Also write isn't a const, you need to drop that const.

    This compiles for me (assuming you stick the class in a header file that is ran through the MOC process.

    
     class MyDazExporter : public DzExporter {
     Q_OBJECT
    public:
    
     /** Constructor **/
      MyDazExporter() : DzExporter(QString("ext")) { };
    
    public slots:
    
      virtual void    getDefaultOptions( DzFileIOSettings *options ) const {};
      virtual QString getDescription() const { return QString("hello"); };
      virtual bool isFileExporter() const { return true; };
    protected:
    
      virtual DzError write( const QString &filename;, const DzFileIOSettings *options ) { return DZ_NO_ERROR; };
    };  
    
    Post edited by msorrels on
  • edited December 1969

    Hi msorrels,

    Thank you very much, that was it!

    SJ

Sign In or Register to comment.