【发布时间】:2017-07-26 08:15:30
【问题描述】:
当我使用以下 QML 文件时,Qt 在运行时报错:
import QtQuick 2.7
import QtQuick.Controls 2.0
Rectangle
{
color: palette.grey
property var spotButtonFunctions :
{
'EditViewTool' : function() {switchToEditViewToolButton.source = "../View/Icons/icon_game.png";},
'SelectTool' : function() {switchToSelectToolButton.source = "../View/Icons/icon_game.png";}
}
property var greyButtonFunctions :
{
'EditViewTool' : function() {switchToEditViewToolButton.source = "../View/Icons/icon_settings.png";},
'SelectTool' : function() {switchToSelectToolButton.source = "../View/Icons/icon_info.png";}
}
// View update slots.
function onNotifyCurrentToolSignal(currentToolName)
{
// Grey all tool buttons.
for (x in greyButtonFunctions)
greyButtonFunctions[x]();
// Spot the current tool button.
if (currentToolName !== "")
spotButtonFunctions[currentToolName]();
}
}
错误信息与for (x in greyButtonFunctions)行有关:
错误:无法将 QString 分配给 double
有什么想法吗?
【问题讨论】:
标签: qt qml qtquick2 qtquickcontrols2