Important: Please read the Qt Code of Conduct -

Declare MetaType object

  • I trying to create a custom object, but when add a Q_DECLARE_METATYPE, I have a compile error like this:
    /opt/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore/qmetatype.h:141: error: call of overloaded 'PluginInfo()' is ambiguous

    Is posible use QMetatype with custom QObject?.

    Here after you can see my header file:

    @#ifndef PLUGININFO_H
    #define PLUGININFO_H

    #include <QObject>
    #include <QMetaType>
    #include <QDebug>
    #include <QtGui>

    class PluginInfo : public QObject

    Q_PROPERTY(QString id READ id WRITE setId RESET resetId)
    Q_PROPERTY(QString fileName READ fileName WRITE setFileName RESET resetFileName)
    Q_PROPERTY(QString name READ name WRITE setName RESET resetName)
    Q_PROPERTY(QString version READ version WRITE setVersion RESET resetVersion)
    Q_PROPERTY(QString summary READ summary WRITE setSummary RESET resetSummary)
    Q_PROPERTY(QString category READ category WRITE setCategory RESET resetCategory)
    Q_PROPERTY(QString applyTo READ applyTo WRITE setApplyTo RESET resetApplyTo)
    Q_PROPERTY(QString author READ author WRITE setAuthor RESET resetAuthor)
    Q_PROPERTY(QString mail READ mail WRITE setMail RESET resetMail)
    Q_PROPERTY(QString webside READ webside WRITE setWebside RESET resetWebside)
    Q_PROPERTY(QString licence READ licence WRITE setLicence RESET resetLicence)
    Q_PROPERTY(QIcon icon READ icon WRITE setIcon RESET resetIcon)
    Q_PROPERTY(bool configurable READ isConfigurable WRITE setConfigurable RESET resetConfigurable)
    Q_PROPERTY(QStringList configList READ configList WRITE setConfigList RESET resetConfigList)

    PluginInfo(const PluginInfo &);

    PluginInfo(QObject *parent = 0);
    QString id() const;
    QString fileName() const;
    QString name() const;
    QString version() const;
    QString summary() const;
    QString category() const;
    QString applyTo() const;
    QString author() const;
    QString mail() const;
    QString webside() const;
    QString licence() const;
    QIcon icon() const;
    bool isConfigurable() const;
    QStringList configList() const;

    QString m_id;
    QString m_fileName;
    QString m_name;
    QString m_version;
    QString m_summary;
    QString m_category;
    QString m_applyTo;
    QString m_author;
    QString m_mail;
    QString m_webside;
    QString m_licence;
    QIcon m_icon;
    bool m_configurable;
    QStringList m_configList;

    public slots:
    void setId(const QString &);
    void setFileName(const QString &);
    void setName(const QString &);
    void setVersion(const QString &);
    void setSummary(const QString &);
    void setCategory(const QString &);
    void setApplyTo(const QString &);
    void setAuthor(const QString &);
    void setMail(const QString &);
    void setWebside(const QString &);
    void setLicence(const QString &);
    void setIcon(const QIcon &);
    void setConfigurable(const bool);
    void setConfigList(const QStringList &);

    void resetAll();
    void resetId();
    void resetFileName();
    void resetName();
    void resetVersion();
    void resetSummary();
    void resetCategory();
    void resetApplyTo();
    void resetAuthor();
    void resetMail();
    void resetWebside();
    void resetLicence();
    void resetIcon();
    void resetConfigurable();
    void resetConfigList();

    PluginInfo& operator =(const PluginInfo &);
    bool operator ==(const PluginInfo &) const;
    friend QDataStream& operator <<(QDataStream &, const PluginInfo &);
    friend QTextStream& operator <<(QTextStream &, const PluginInfo &);



    #endif // PLUGININFO_H

  • Moderators

    Yeap, ‘PluginInfo()’ is ambiguous. See lines 29 and 33.

  • Oh!!! Tobias,

    Thank you, yes I was a fool. QObject parent = 0 is default constructor.

    Best regards,

Log in to reply