Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Cross-Thread signal: Cannot queue arguments of type 'QVector<QVector<int> >
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 50.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jlunz
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    1
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      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.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      1
      • J Offline
        J Offline
        Jlunz
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          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

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved