0

Error:

error: no matching function for call to ‘QArgument<QString>::QArgument(
    const char [8],
   __gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, 
   std::__cxx11::basic_string<char> >::value_type&)’

At:

QMetaObject::invokeMethod(
    mReceiver, 
    "setname", 
    Qt::QueuedConnection, 
    Q_ARG(QString, "test"));

Here is the error that I am facing when using QString as the parameter of Q_ARG() in QMetaObject::invokeMethod. So may I know is there any solution to this problem?

2
  • 2
    Try to invoke the constructor explicitly like this: QString("test") Commented Sep 28, 2021 at 15:21
  • Please provide a minimal-reproducible-example Commented Sep 29, 2021 at 15:28

1 Answer 1

1

I found that we can directly convert the string to QString in Q_ARG() to prevent this error:

QMetaObject::invokeMethod(
    mReceiver, 
    "setname", 
    Qt::QueuedConnection, 
    Q_ARG(QString, QString::fromStdString("test")));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.