Unsolved Cannot queue arguments of type...
-
@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>();
-
@kshegunov I done this before, first placed in .h outclass scope(after includes), second in constructor. Both in mainWindow class. Still that error.
Also tried to place it in worker class, same result.
-
Can you show how you have done qRegisterMetaType for signed long long ?
-
@Engelard Actually from my own praxis I don't see long long used really often (and I guess this is the reason why this type isn't registered by default). In most cases a simple int is enough. Do you really need 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?
-
@Savitha
Did you tryQ_DECLARE_METATYPE(quint32)
as well asQ_DECLARE_METATYPE(quint32&)
? Other than that you will have to await someone who knows about this. -
-
A slot can not take non-const references. Especially not when it's a queued connection.