Мое приложение использует вкладки, и один из них показывает веб-страницу с помощью WebView. Теперь у меня есть панель инструментов с одной кнопкой действия, в которой я хочу показать диалог - но это не так.
Вместо этого я получаю это сообщение об ошибке при нажатии кнопки действия:
file:///usr/lib/x86_64-linux-gnu/qt5/qml/Ubuntu/Components/Popups/popupUtils.js:50: Error: Cannot assign QObject* to QQuickItem*
Показывает, что WebView работает с одним и тем же компонентом и диалогом. Почему это не работает, и что мне делать, чтобы это стало возможным? Я действительно хочу, чтобы этот диалог был там.
Вот часть моего кода:
// Change coordinates dialog
Component {
id: dialog
Dialog {
id: dialogue
title: "Save file"
text: "Are you sure that you want to save this file?"
// X
TextField {
id: xCoo
width: units.gu(20)
placeholderText: 'X'
text: xCurrent
}
// Y
TextField {
id: yCoo
width: units.gu(20)
placeholderText: 'Y'
text: yCurrent
}
Button {
id: 'goButton'
text: 'Go'
color: 'green'
onClicked: {
xCurrent = xCoo.text
yCurrent = yCoo.text
PopupUtils.close(cooDialog)
}
}
}
}
WebView {
id: mapContent
anchors.fill: parent
url: "http://webpage.html"
smooth: true
scale: 1
visible: true
}
И действие:
// Change coordinates
Action {
id: coordinateAction
objectName: "action2"
iconSource: Qt.resolvedUrl("toolbarIcon.png")
text: i18n.tr("Coordinates")
onTriggered: {
PopupUtils.open(dialog, coordinateAction)
}
}