![](/img/trans.png)
[英]QtQuick - qml:28: Error: Unknown method return type: custom type
[英]QML Error: Unknown method return type: std::string
我使用 QML。 我有這個 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 = "";
};
在 QML 中,我這樣做:
Text {
font.pixelSize: 25
height: 30
text: showTime.whatToShow(index)
}
但結果我收到一個錯誤:
錯誤:未知方法返回類型: std::string 。
我究竟做錯了什么?
@GrecKo 是的,它有幫助。 謝謝你。 我將 std::string 更改為 QString。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.