Unable to show Popups Dialog in tab with webview

Tags:

Answer: 1

30 hours ago

My app uses tabs, and one of them shows a web page using WebView. Now, I have a toolbar with one action button that I want to show a Dialog - but it's no go.

Instead I get this error message when pressing the action button:

file:///usr/lib/x86_64-linux-gnu/qt5/qml/Ubuntu/Components/Popups/popupUtils.js:50: Error: Cannot assign QObject* to QQuickItem*

Showing in a tab whitout a WebView works fint with the same Component and Dialog. Why does it not work, and what should I do to make it possible? I'd really want this dialog there.

Here's part of my code:

            // 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
                }

And the action:

                // Change coordinates
                Action {
                    id: coordinateAction
                    objectName: "action2"

                    iconSource: Qt.resolvedUrl("toolbarIcon.png")
                    text: i18n.tr("Coordinates")

                    onTriggered: {
                        PopupUtils.open(dialog, coordinateAction)
                    }
                }
Added by: Norval Dickinson

Answer: 2

16 hours ago

Actually, it was really simple. What I did was that I changed the onTriggered signal to: PopupUtils.open(dialog, mapContent) where mapContent is the ID of the webview. Now the dialog works as it should!

Added by: Sarina Grant Jr.

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9