【问题标题】:Can't access some supposedly public properties on the QKeyEvent object无法访问 QKeyEvent 对象上的一些所谓的公共属性
【发布时间】:2018-12-14 07:45:56
【问题描述】:

这里有一个公共属性列表:http://doc.qt.io/qt-5/qkeyevent.html

我尝试访问它们:

            Keys.onPressed: {
                console.log("matches: ", event.matches("="));
                console.log("text: ", event.text());
                console.log("native modifiers: ", event.nativeModifiers());
                console.log("native scan code: ", event.nativeScanCode());
                console.log("native virtual key: ", event.nativeVirtualKey());
            }

我可以访问matches 属性,但不能访问其他属性。

24.317 D: onPressed: matches:  false
24.317 W: unknown: ...: TypeError: Property 'text' of object QQuickKeyEvent(0x10e6cad90) is not a function

为什么?

【问题讨论】:

    标签: qml qkeyevent


    【解决方案1】:

    因为您是作为函数调用访问属性。

    只需改用event.text。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多