[SOLVED] Cross-Thread signal: Cannot queue arguments of type 'QVector<QVector<int> >



  • Hi!

    I have a small problem concerning two threads and signals/slots connected between them.

    My connect looks like this.
    @
    ...
    qRegisterMetaType<QVector<QVector<int> > >("MyArray");
    ...
    connect(sender, SIGNAL(dataChanged(QVector<QVector<int> >)), receiver, SLOT(hasDataChanged(QVector<QVector<int> >)));
    @

    If the signal is being emitted, I get this error:
    @
    QObject::connect: Cannot queue arguments of type 'QVector<QVector<int> >'
    (Make sure 'QVector<QVector<int> >' is registered using qRegisterMetaType().)
    @

    Also note that I have my sig/slots with a reference, but if I used a connect like this:
    @
    connect(sender, SIGNAL(dataChanged(QVector<QVector<int> >&)), receiver, SLOT(hasDataChanged(QVector<QVector<int> >&)));
    @
    I'm getting this:
    Object::connect: No such signal dataChanged(QVector<QVector<int> >&)

    Sender
    @
    signals:
    void dataChanged(const QVector<QVector<int> > &data);
    @

    Receiver
    @
    public slots:
    void hasDataChanged(const QVector<QVector<int> > &data);
    @

    How can I achieve a connection, do I need to put Q_DECLARE_METATYPE somewhere?

    Thanks for your help!



  • You should do a typedef:

    @
    typedef QVector<QVector<int> > MyArray;
    // ...
    qRegisterMetaType<MyArray>("MyArray");
    // ...
    connect(
    this, SIGNAL(blurbDone2(MyArray)),
    this, SLOT(slotBlurb2(MyArray)),
    Qt::QueuedConnection);

    // with this signatures:
    signals:
    void blurbDone2(const MyArray &bb);

    protected slots:
    void slotBlurb2(const MyArray &bb);
    @

    This works for me.



  • Yess, also works for me!

    I pulled the typedef out in a seperate header file, now it's working like a charm.

    Any reason why connect can't handle this w/o a typedef?



  • The reason could be that QVector is a built-in type and that somehow confuses the meta object system. Maybe it's worth opening an issue in the "bug tracker":bugreports.qt.nokia.com


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.