15

我有这个信号

class SystemUICfgScanner 
{
    /*code here*/
signals:
    void error(QString desc);
    /*more code*/
};

在 QML 中,我以这种方式使用 InfoBanner:

InfoBanner
{
    property string infodetails: ""
    id: systemuicfgErrorBanner
    text: "Error: " + infodetails
    Connections
    {
        target: cfgScanner
        onError: infodetails = desc
    }
}

发出错误(QString)信号时,我收到此错误

Invalid write to global property "infodetails"

我究竟做错了什么?

提前致谢

4

1 回答 1

17

尝试InfoBanner通过 id 引用实例:

InfoBanner
{
    property string infodetails: ""
    id: systemuicfgErrorBanner
    text: "Error: " + infodetails
    Connections
    {
        target: cfgScanner
        onError: systemuicfgErrorBanner.infodetails = desc
    }
}
于 2012-09-06T17:03:11.447 回答