Important: Please read the Qt Code of Conduct -

[QtScript] registering and handling QPair

  • I have a few slots that return a QPair and I would like to call them from a script.

    I'm trying to register QPair but @Q_DECLARE_METATYPE(QPair<bool,QString>)@ won't compile.
    I've found this commit:
    where is declared:
    Allows a metatype to be declared for a type containing a single comma.
    For example:
    Q_DECLARE_METATYPE2(QList<QPair<QByteArray,QByteArray> >)
    template <>
    struct QMetaTypeId< TYPE1,TYPE2 >
    enum { Defined = 1 };
    static int qt_metatype_id()
    static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
    if (!metatype_id)
    metatype_id = qRegisterMetaType< TYPE1,TYPE2 >( #TYPE1 "," #TYPE2 );
    return metatype_id;

    This time @Q_DECLARE_METATYPE2(QPair<bool,QString>)@ will compile but it triggers an infinitely recursive loop at execution.

    Any help will be much appreciated

Log in to reply