QObject::connect: Cannot queue arguments of type
-
@micha_eleric No no, it's not necessary to register anything. because QList is automatically registered by Qt and basic types do not need to be registered either.
wrote on 27 Nov 2023, 07:02 last edited by@HaoTian Indeed, you are correct. This, for example, works:
#include <QCoreApplication> #include <QObject> #include <QList> #include <QDebug> #include <QTimer> class Object: public QObject { Q_OBJECT public: Object(QObject *p = nullptr): QObject(p) { QTimer::singleShot( 5000, this, [this]() { emit send(QList<float> { 0, 1.2, 2.3, 3.4 } ); } ); }; ~Object() { } public slots: void receive(QList<float> list) { qDebug() << list; } signals: void send(QList<float> list); }; int main(int argc, char **argv) { QCoreApplication app(argc, argv); Object *a = new Object(qApp); Object *b = new Object(qApp); QObject::connect(a, &Object::send, b, &Object::receive); return app.exec(); } #include "main.moc"
So, @micha_eleric, what are you not telling us? Are there threads involved? Can you modify the example above to fail in the same way?
-
int id = qRegisterMetaType< QList<float> >();
is in both classes that use QList<float>, and still get the error
wrote on 27 Nov 2023, 08:11 last edited by@micha_eleric
First you should get your code compiling and running correctly as per @ChrisW67. You will need to use theQ_OBJECT
macro., and you should useconnect()
syntax shown, notSIGNAL
/SLOT()
macros.But you may end up needing to reconsider your array/list arguments to the signal/slot. I assume you are signalling across threads. Qt will copy any arguments. If your array is "large" or if you intend to update the array in the slot (not just read from it) you may/will need to reconsider.
-
@HaoTian Indeed, you are correct. This, for example, works:
#include <QCoreApplication> #include <QObject> #include <QList> #include <QDebug> #include <QTimer> class Object: public QObject { Q_OBJECT public: Object(QObject *p = nullptr): QObject(p) { QTimer::singleShot( 5000, this, [this]() { emit send(QList<float> { 0, 1.2, 2.3, 3.4 } ); } ); }; ~Object() { } public slots: void receive(QList<float> list) { qDebug() << list; } signals: void send(QList<float> list); }; int main(int argc, char **argv) { QCoreApplication app(argc, argv); Object *a = new Object(qApp); Object *b = new Object(qApp); QObject::connect(a, &Object::send, b, &Object::receive); return app.exec(); } #include "main.moc"
So, @micha_eleric, what are you not telling us? Are there threads involved? Can you modify the example above to fail in the same way?
@ChrisW67 said in QObject::connect: Cannot queue arguments of type:
@HaoTian Indeed, you are correct. This, for example, works:
#include <QCoreApplication> #include <QObject> #include <QList> #include <QDebug> #include <QTimer> class Object: public QObject { Q_OBJECT public: Object(QObject *p = nullptr): QObject(p) { QTimer::singleShot( 5000, this, [this]() { emit send(QList<float> { 0, 1.2, 2.3, 3.4 } ); } ); }; ~Object() { } public slots: void receive(QList<float> list) { qDebug() << list; } signals: void send(QList<float> list); }; int main(int argc, char **argv) { QCoreApplication app(argc, argv); Object *a = new Object(qApp); Object *b = new Object(qApp); QObject::connect(a, &Object::send, b, &Object::receive); return app.exec(); } #include "main.moc"
So, @micha_eleric, what are you not telling us? Are there threads involved? Can you modify the example above to fail in the same way?
If I may just add something: use const references, this will avoid potentially expensive copies when possible.
-
@micha_eleric No no, it's not necessary to register anything. because QList is automatically registered by Qt and basic types do not need to be registered either.
wrote on 27 Nov 2023, 20:45 last edited by@HaoTian which is why I wonder why it gives this error when it runs
QObject::connect: Cannot queue arguments of type 'QList<float>' (Make sure 'QList<float>' is registered using qRegisterMetaType().)
-
@HaoTian Indeed, you are correct. This, for example, works:
#include <QCoreApplication> #include <QObject> #include <QList> #include <QDebug> #include <QTimer> class Object: public QObject { Q_OBJECT public: Object(QObject *p = nullptr): QObject(p) { QTimer::singleShot( 5000, this, [this]() { emit send(QList<float> { 0, 1.2, 2.3, 3.4 } ); } ); }; ~Object() { } public slots: void receive(QList<float> list) { qDebug() << list; } signals: void send(QList<float> list); }; int main(int argc, char **argv) { QCoreApplication app(argc, argv); Object *a = new Object(qApp); Object *b = new Object(qApp); QObject::connect(a, &Object::send, b, &Object::receive); return app.exec(); } #include "main.moc"
So, @micha_eleric, what are you not telling us? Are there threads involved? Can you modify the example above to fail in the same way?
wrote on 27 Nov 2023, 20:47 last edited by@ChrisW67 it is with threads, and the only place I have seen
QObject::connect: Cannot queue arguments of type 'QList<float>' (Make sure 'QList<float>' is registered using qRegisterMetaType().)
show while running
-
@micha_eleric
First you should get your code compiling and running correctly as per @ChrisW67. You will need to use theQ_OBJECT
macro., and you should useconnect()
syntax shown, notSIGNAL
/SLOT()
macros.But you may end up needing to reconsider your array/list arguments to the signal/slot. I assume you are signalling across threads. Qt will copy any arguments. If your array is "large" or if you intend to update the array in the slot (not just read from it) you may/will need to reconsider.
wrote on 27 Nov 2023, 20:58 last edited by@JonB said in QObject::connect: Cannot queue arguments of type:
@micha_eleric
First you should get your code compiling and running correctly as per @ChrisW67. You will need to use theQ_OBJECT
macro., and you should useconnect()
syntax shown, notSIGNAL
/SLOT()
macros.But you may end up needing to reconsider your array/list arguments to the signal/slot. I assume you are signalling across threads. Qt will copy any arguments. If your array is "large" or if you intend to update the array in the slot (not just read from it) you may/will need to reconsider.
it compiles and runs, but
QObject::connect: Cannot queue arguments of type 'QList<float>' (Make sure 'QList<float>' is registered using qRegisterMetaType().)
shows on console while running
-
@JonB said in QObject::connect: Cannot queue arguments of type:
@micha_eleric
First you should get your code compiling and running correctly as per @ChrisW67. You will need to use theQ_OBJECT
macro., and you should useconnect()
syntax shown, notSIGNAL
/SLOT()
macros.But you may end up needing to reconsider your array/list arguments to the signal/slot. I assume you are signalling across threads. Qt will copy any arguments. If your array is "large" or if you intend to update the array in the slot (not just read from it) you may/will need to reconsider.
it compiles and runs, but
QObject::connect: Cannot queue arguments of type 'QList<float>' (Make sure 'QList<float>' is registered using qRegisterMetaType().)
shows on console while running
@micha_eleric Which version of Qt are you running ?
-
@micha_eleric Which version of Qt are you running ?
wrote on 27 Nov 2023, 21:13 last edited by@SGaist said in QObject::connect: Cannot queue arguments of type:
@micha_eleric Which version of Qt are you running ?
been asked this before, and still no clue how to find out. All I can find is the version of the editor.
-
@SGaist said in QObject::connect: Cannot queue arguments of type:
@micha_eleric Which version of Qt are you running ?
been asked this before, and still no clue how to find out. All I can find is the version of the editor.
wrote on 27 Nov 2023, 21:20 last edited by -
wrote on 27 Nov 2023, 22:04 last edited by
@Abderrahmene_Rayene said in QObject::connect: Cannot queue arguments of type:
@micha_eleric said in QObject::connect: Cannot queue arguments of type:
how to find out
instructions do not work for my version of QT Create, and once i did find preference->kit->kit, nothing was listed under auto-detected nor manual
-
@Abderrahmene_Rayene said in QObject::connect: Cannot queue arguments of type:
@micha_eleric said in QObject::connect: Cannot queue arguments of type:
how to find out
instructions do not work for my version of QT Create, and once i did find preference->kit->kit, nothing was listed under auto-detected nor manual
@micha_eleric said in QObject::connect: Cannot queue arguments of type:
once i did find preference->kit->kit, nothing was listed under auto-detected nor manual
That sounds very strange.
What do you see when you try Step #2 in the instructions?
-
@micha_eleric said in QObject::connect: Cannot queue arguments of type:
once i did find preference->kit->kit, nothing was listed under auto-detected nor manual
That sounds very strange.
What do you see when you try Step #2 in the instructions?
wrote on 28 Nov 2023, 02:04 last edited by@JKSH said in QObject::connect: Cannot queue arguments of type:
@micha_eleric said in QObject::connect: Cannot queue arguments of type:
once i did find preference->kit->kit, nothing was listed under auto-detected nor manual
That sounds very strange.
What do you see when you try Step #2 in the instructions?
lol, second step also gave no version, but can find editor version elsewhere
Qt Creator 6.0.2
Based on Qt 5.15.3 (GCC 11.2.0, 64 bit) -
@JKSH said in QObject::connect: Cannot queue arguments of type:
@micha_eleric said in QObject::connect: Cannot queue arguments of type:
once i did find preference->kit->kit, nothing was listed under auto-detected nor manual
That sounds very strange.
What do you see when you try Step #2 in the instructions?
lol, second step also gave no version, but can find editor version elsewhere
Qt Creator 6.0.2
Based on Qt 5.15.3 (GCC 11.2.0, 64 bit)wrote on 28 Nov 2023, 02:38 last edited by Pl45m4@micha_eleric said in QObject::connect: Cannot queue arguments of type:
Qt Creator 6.0.2
Based on Qt 5.15.3 (GCC 11.2.0, 64 bit)This is meaningless. It's the Qt version which was used to build your QtCreator version.
How are your build folders named? In some case they are named by default like:
build_<Projectname>_<QtX_X_X>_<Compiler>_<Architecture>
There you also can find out what Qt version you are using
-
@micha_eleric said in QObject::connect: Cannot queue arguments of type:
Qt Creator 6.0.2
Based on Qt 5.15.3 (GCC 11.2.0, 64 bit)This is meaningless. It's the Qt version which was used to build your QtCreator version.
How are your build folders named? In some case they are named by default like:
build_<Projectname>_<QtX_X_X>_<Compiler>_<Architecture>
There you also can find out what Qt version you are using
wrote on 28 Nov 2023, 02:51 last edited by@Pl45m4 said in QObject::connect: Cannot queue arguments of type:
@micha_eleric said in QObject::connect: Cannot queue arguments of type:
Qt Creator 6.0.2
Based on Qt 5.15.3 (GCC 11.2.0, 64 bit)This is meaningless. It's the Qt version which was used to build your QtCreator version.
How are your build folders named? In some case they are named by default like:
build_<Projectname>_<QtX_X_X>_<Compiler>_<Architecture>
There you also can find out what Qt version you are using
again nothing of use, "build-GraphicsView-Desktop-Debug"
-
@Pl45m4 said in QObject::connect: Cannot queue arguments of type:
@micha_eleric said in QObject::connect: Cannot queue arguments of type:
Qt Creator 6.0.2
Based on Qt 5.15.3 (GCC 11.2.0, 64 bit)This is meaningless. It's the Qt version which was used to build your QtCreator version.
How are your build folders named? In some case they are named by default like:
build_<Projectname>_<QtX_X_X>_<Compiler>_<Architecture>
There you also can find out what Qt version you are using
again nothing of use, "build-GraphicsView-Desktop-Debug"
wrote on 28 Nov 2023, 03:03 last edited by@micha_eleric well, after pecking around, i found:
Qt 4.8.7 in PATH (qt4) /usr/lib/x86_64-linux-gnu/qt4/bin/qmake
Qt 5.15.3 in PATH (qt5) /usr/lib/qt5/bin/qmake
Qt 5.15.3 in PATH (System) /usr/bin/qmake -
wrote on 28 Nov 2023, 03:08 last edited by
i found another post that said to add
Q_DECLARE_METATYPE(QList<qfloat16>)
but still gave same error while running.
-
@JKSH said in QObject::connect: Cannot queue arguments of type:
@micha_eleric said in QObject::connect: Cannot queue arguments of type:
once i did find preference->kit->kit, nothing was listed under auto-detected nor manual
That sounds very strange.
What do you see when you try Step #2 in the instructions?
lol, second step also gave no version, but can find editor version elsewhere
Qt Creator 6.0.2
Based on Qt 5.15.3 (GCC 11.2.0, 64 bit)wrote on 28 Nov 2023, 03:15 last edited by@micha_eleric If you are on Ubuntu 22.04 (a guess on my part), have not installed a Qt version separately from that installed by Ubuntu, and everything is up-to-date then you are using Qt 5.15.3.
Open a terminal and type
qmake -v
-
@micha_eleric If you are on Ubuntu 22.04 (a guess on my part), have not installed a Qt version separately from that installed by Ubuntu, and everything is up-to-date then you are using Qt 5.15.3.
Open a terminal and type
qmake -v
wrote on 28 Nov 2023, 03:21 last edited by@ChrisW67 said in QObject::connect: Cannot queue arguments of type:
@micha_eleric If you are on Ubuntu 22.04 (a guess on my part), have not installed a Qt version separately from that installed by Ubuntu, and everything is up-to-date then you are using Qt 5.15.3.
Open a terminal and type
qmake -v
QMake version 3.1
Using Qt version 5.15.3 in /usr/lib/x86_64-linux-gnu -
wrote on 28 Nov 2023, 03:25 last edited by
in .h file, but only in one .h file
Q_DECLARE_METATYPE(QList<qfloat16>) //data int id;
in .cpp file, constructor
id = qRegisterMetaType< QList<qfloat16> >();
-
-
@Pl45m4 said in QObject::connect: Cannot queue arguments of type:
@micha_eleric said in QObject::connect: Cannot queue arguments of type:
Qt Creator 6.0.2
Based on Qt 5.15.3 (GCC 11.2.0, 64 bit)This is meaningless. It's the Qt version which was used to build your QtCreator version.
How are your build folders named? In some case they are named by default like:
build_<Projectname>_<QtX_X_X>_<Compiler>_<Architecture>
There you also can find out what Qt version you are using
again nothing of use, "build-GraphicsView-Desktop-Debug"
This post is deleted!
16/27