I use QML. Ihave this c++ code
#include <QObject>
class ShowTime : public QObject
{
Q_OBJECT
public:
explicit ShowTime(QObject *parent = nullptr);
Q_INVOKABLE std::string whatToShow(int index);
private:
std::string mWhatToShow = "";
};
In QML I do this:
Text {
font.pixelSize: 25
height: 30
text: showTime.whatToShow(index)
}
But as a result I get an error:
Error: Unknown method return type: std::string .
What am I doing wrong?
@GrecKo Yes it helped. Thank you. I changed std::string to QString.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.