Re: What data type is the text in addAction(tr("&First Item"))
This code comes from the grouppushbuttonbox example at
http://doc.qt.io/qt-5/qtwidgets-widg...x-example.html
At run time I want to build a string to replace the ("&First Item") with a concatenated integer. It fails to compile saying that std::string is in valid for the argument. QString fails for the same reason.
There has to be a way of changing this text at startup. Any help would be appreciated.
Thank You
emp1953
Added after 25 minutes:
Here is the compiler error
/home/123/groupbox_example/window.cpp:102: error: no matching function for call to 'Window::tr(std::string&)'
menu->addAction(tr(str));
^
Re: What data type is the text in addAction(tr("&First Item"))
QObject::tr() takes a const char* as first argument: http://doc.qt.io/qt-5/qobject.html#tr
Re: What data type is the text in addAction(tr("&First Item"))
So this would work:
Code:
menu->addAction( tr( str.c_str() ) );
When you get a "no matching function call" compiler error it almost always means you have 1) spelled the name of the function incorrectly, 2) are trying to call the function with the wrong type of argument, or 3) are calling it with the wrong number of arguments.
The Qt documentation is always your friend.
Re: What data type is the text in addAction(tr("&First Item"))
Quote:
Originally Posted by
d_stranz
So this would work:
Code:
menu->addAction( tr( str.c_str() ) );
When you get a "no matching function call" compiler error it almost always means you have 1) spelled the name of the function incorrectly, 2) are trying to call the function with the wrong type of argument, or 3) are calling it with the wrong number of arguments.
The Qt documentation is always your friend.
Thank you d_stranz, it did work.