[英]QML Error: Unknown method return type: std::string
I use QML.我使用 QML。 Ihave this c++ code
我有这个 C++ 代码
#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:在 QML 中,我这样做:
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 .
错误:未知方法返回类型: std::string 。
What am I doing wrong?我究竟做错了什么?
@GrecKo Yes it helped. @GrecKo 是的,它有帮助。 Thank you.
谢谢你。 I changed std::string to QString.
我将 std::string 更改为 QString。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.