Cannot queue arguments of type...
-
Hi guys, i know that similar topic was here recently, but this one much more simple and precise.
I created new project with name "tests", the only significant thing i did - added new class of worker so i'd be able use QThreads. But it still absolutely simple. Here how the program works:
When program starts - function in worker object called, it runs eternally, if trigger variable is true - signal emits message in mainWindow(it will mean that everything works):
void worker::mainFlow() { while(true) { if(trigger) sentInt(75); Sleep(1000); } }
Here how connect looks in main constructor:
connect(w1, SIGNAL(sentInt(int)), this, SLOT(receiveInt(int)));
Such simple app works, but if i change parameters from int to "signed long long" it will give message during runtime and signal won't be emitted:
QObject::connect: Cannot queue arguments of type 'signed long long'
(Make sure 'signed long long' is registered using qRegisterMetaType().)No matter how much i read stuff from google, nothing helps. Some offer use qRegisterMetaType() - it changes nothing, some - update Qt, but i already have last version 5.12.
In my recent 5.10 was no such problems, what should ordinary users do, to resolve such basic stuff?
-
@Engelard said in Cannot queue arguments of type...:
but if i change parameters from int to "signed long long"
You can use qint64. If you really want to use long long you need to register it first like the error message suggests.
-
@Engelard said in Cannot queue arguments of type...:
but i already have last version 5.12
Then just use the new syntax:
connect(w1, &worker::sentInt, this, &mainWindow::receiveInt);
-
@VRonin Hey, that is good one feature, thanks.
@jsulm said in Cannot queue arguments of type...:
If you really want to use long long you need to register it first like the error message suggests.
Why? I really can not understand, it's basic type which is often used by everyone everywhere, it's not some vector or some custom type... And i can't find single simple example for "qt register meta type" in google. I'd understood if i want to pass my custom type like struct or so, but it is essential type. qRegisterMetaType<signed long long>() - do nothing.
-
@Engelard said in Cannot queue arguments of type...:
Why? I really can not understand, it's basic type which is often used by everyone everywhere, it's not some vector or some custom type...
Doesn't matter. Qt has to know how to pack it for queued message transmission.
And i can't find single simple example for "qt register meta type" in google. I'd understood if i want to pass my custom type like struct or so, but it is essential type. qRegisterMetaType<signed long long>() - do nothing.
Usually it goes in a pair:
Q_DECLARE_METATYPE(TypeName)
goes in the header, and then in the source at runtime registration is done with:
qRegisterMetaType<TypeName>();
-
Can you show how you have done qRegisterMetaType for signed long long ?
-
-
There is quite nothing to show really
In Header:Q_DECLARE_METATYPE(signed long long)
CPP file(in constructor):
qRegisterMetaType<signed long long>();
@jsulm if such type would be unnecessary - it would not exist, i do need it because of big whole numbers which billions.
-
Try. qRegisterMetaType<signed long long>("signed long long");
Check the complete example in my git repository -
@dheerendra said in Cannot queue arguments of type...:
Try. qRegisterMetaType<signed long long>("signed long long");
That is correct answer. But in previous topic someone told me that "leave parentheses empty"))
P.S. i found that it working without macro, so only qRegisterMetaType<signed long long>("signed long long"); is enough
-
@Engelard said in Cannot queue arguments of type...:
if such type would be unnecessary - it would not exist
Where did I say it is unnecessary?!
Please stay objective! -
@Engelard said in Cannot queue arguments of type...:
P.S. i found that it working without macro, so only qRegisterMetaType<signed long long>("signed long long"); is enough
hmmm. I did not see any body suggesting like this. Everybody suggested to use the qRegisterMetaType. I was suspecting the way you have done. Hence i asked the code.
-
@Engelard said in Cannot queue arguments of type...:
That is correct answer. But in previous topic someone told me that "leave parentheses empty"))
That someone explained you why as stated in the documentation of qRegisterMetatype.
-
Now your issue is fixed, you can move the issue to SOLVED state. It helps others.
-
Hi All,
I know the solution has been provided to this problem but it is not working for me.
Here is my code,
Class2.hpp
void slot_ofClass2(quint32 &p_Result, QVector<quint32> &p_Values,
Error& p_error);Class1.hpp
void signal_fromClass1(quint32& p_Result, QVector<quint32>& p_Values,
Error& p_error);Class1.cpp
QObject::connect(this, &Class1::signal_fromClass1, loc_class2Obj.data(), &Class2::slot_ofClass2, Qt::QueuedConnection);
I have added Q_DECLARE_METATYPE(quint32) in Class2.hpp which is included in Class1.hpp and
qRegisterMetaType<quint32>("quint32"); in both the Constructors of Class1 and Class2.It is still giving the error"QObject::connect: Cannot queue arguments of type 'quint32&'
(Make sure 'quint32&' is registered using qRegisterMetaType().)"What am I missing?
-
@Savitha
I don't know anything about QML/registering meta types, so no point quizzing me further, but looking at the error message and your signal/slot parameters you have registeredquint32
but your methods requirequint32&
. With QML/register meta-type maybe it cannot go fromquint32
toquint32&
? If so, either registerquint32&
or change your parameters toquint32
to see if that works?There is little point in passing integer-types as references anyway.[Whoops, I didn't realize you are changing the value.] -
@JonB Thank you for the reply.
If I change my parameters to quint32 it connects to the slot. But my slot_ofClass2 is updating these values which I will be handling in Class1 so I need quint32&.If I try Q_DECLARE_METATYPE(quint32&) it gives error: 'type name' declared as a pointer to a reference of type 'quint32 &' (aka 'unsigned int &')
and qRegisterMetaType<quint32&>("quint32&"); gives error: no matching function for call to 'qRegisterMetaType<quint32&>(const char [9], quint32*)'Any solution to handle this problem with references?
I have seen an example with (QString const& s) as a parameter and this works without having to register it as MetaType. So is there any workaround?