gpt4 book ai didi

c++ - Qt Quick ui形式不支持功能

转载 作者:行者123 更新时间:2023-12-02 10:08:34 24 4
gpt4 key购买 nike

我试图在Qt Quick应用程序中打开一个链接,收到functions are not supported in Qt Quick ui form警告,该应用程序正常工作,我想摆脱该警告,如何解决此警告?
AboutForm.ui.qml文件

Text {
id: license
x: 40
y: 207
color: "#ffffff"
text: qsTr("<a href='https://www.gnu.org/licenses/old-licenses/gpl-2.0.html'>GNU General Public License, version 2 or later</a>")
font.pixelSize: 16
// the editor complains about this function
onLinkActivated: Qt.openUrlExternally("https://www.gnu.org/licenses/old-licenses/gpl-2.0.html")

MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
}

我的 About.qml文件为空。
import QtQuick 2.4

AboutForm {

}

最佳答案

根据docs:

You can use Qt Creator wizards to create UI forms that have the filename extension .ui.qml. The UI forms contain a purely declarative subset of the QML language. It is recommended that you edit the forms in the Design mode. However, exporting items as alias properties is a commercial only feature, and therefore you must use the Edit mode to do it if you are using the open source version of Qt Creator. Qt Creator enforces the use of the supported QML features by displaying error messages.

The following features are not supported:

  • JavaScript blocks
  • Function definitions
  • Function calls (except qsTr)
  • Other bindings than pure expressions
  • Signal handlers
  • States in other items than the root item
  • Root items that are not derived from QQuickItem or Item

The following types are not supported:

  • Behavior
  • Binding
  • Canvas
  • Component
  • Shader Effect
  • Timer
  • Transform
  • Transition


我建议的解决方案是通过以下方式禁止显示警告:
// @disable-check M222
onLinkActivated: Qt.openUrlExternally(
"https://www.gnu.org/licenses/old-licenses/gpl-2.0.html")

引用文献:
  • https://forum.qt.io/topic/66429/what-is-sign-in-disable-check-m16
  • http://doc.qt.io/qtcreator/creator-checking-code-syntax.html#list-of-javascript-and-qml-checks
  • 关于c++ - Qt Quick ui形式不支持功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47742009/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com