QT快速UI表单不支持函数
functions are not supported in Qt Quick ui form
我正在尝试在QT快速应用程序中打开一个链接,我得到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 {
}
根据文档:
您可以使用QT创建者向导创建具有文件名扩展名.UI.QML的UI表单。UI形式包含QML语言的纯声明子集。建议您在设计模式下编辑表单。但是,将项目作为别名属性是一个仅商业功能,因此,如果您使用QT Creator的开源版本,则必须使用编辑模式来执行此操作。QT创建者通过显示错误消息来强制使用受支持的QML功能。
不支持以下功能:
- JavaScript块
- 功能定义
- 函数呼叫(QSTR除外)
- 纯表达式以外的其他绑定
- 信号处理程序
- 除根项目以外的其他项目中的状态
- 未从qquickitem或item item
派生的根项目不支持以下类型:
- 行为
- 绑定
- 画布
- 组件
- 着色器效果
- 计时器
- 变换
- 过渡
我建议的解决方案是用以下内容抑制警告:
// @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-javascript-and-javascript-and-qml-checks
关于form.ui.qml
// add this:
property alias license: license
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
// Remove this line
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
}
大约qml
import QtQuick 2.4
AboutForm {
// add this line
license.onLinkActivated: Qt.openUrlExternally("https://www.gnu.org/licenses/old-licenses/gpl-2.0.html")
}
qt快速UI表单应该是一个只有可见元素的QML文件。这里没有商业逻辑(qt-forum)。
使用QT创建者创建QT快速UI表单时,它将创建两个文件:
- youritemform.ui.qml
- youritem.qml&lt; ---这包括逻辑。
YourItem.qml
:
YourItemForm {
button1 {
text: data_provider.get("button_text")
}
}
YourItemForm.ui.qml
:
Item {
property alias button1 : button1
Button {
id: button1
}
}
我建议从main.qml开放外部链接,而不是从UI本身打开。
在aboutform.ui.qml中添加
属性int Internexall:1
MouseArea {
id: mousearea
anchors.fill: parent
drag.target: parent
onClicked: externalcall=2
}
然后在Main.QML应用程序窗口内部创建一个On On On On On OfectionCall更改,并在此功能中打开链接。如果不清楚,请让我知道一个例子。
相关文章:
- Casablanca/cpprestsdk listener.support接受函数,但不支持方法
- 为什么向量不支持 size 作为成员变量,就像 Java 类中的长度变量一样,而是函数 size()?
- C++11 NVCC 不支持函数 iota()?
- 如何将 MATLAB 图像处理库内置函数转换为 MATLAB 编码器代码生成不支持的 C++?
- PGI 不支持 OpenMP 4.5 运行时函数
- createProcessWithLogon返回不支持的函数
- QT快速UI表单不支持函数
- 错误C4430:丢失类型指定词 - 假设INT.注意:C 不支持对我的构造函数的默认设置
- 聚合初始化不支持构造函数访问
- 为什么 g++ 不支持在 Ubuntu 上使用分配器构造函数?
- 为什么 C++ 标准支持函数 strftime 而不是 strptime
- 我的 cipher() 函数似乎不支持大写字母
- Matlab 编码器不支持的函数
- 函数指针是否不支持C++中的实例类型
- clang 3.5中不支持-finline函数
- Matlab Codegen:不支持匿名函数
- java.lang.IllegalArgumentException:函数参数0处不支持的参数
- 为什么C++"标准"不支持另一个函数中的函数定义?
- 为什么 gcc 不支持裸函数?
- 独立代码生成不支持函数'uigetfile'