Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Back button click Android not registered in Qt Webview

Back button click Android not registered in Qt Webview

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
qt5.10qmlandroidhtml
1 Posts 1 Posters 909 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ramonn
    wrote on 19 Mar 2018, 12:37 last edited by
    #1

    I am creating a small Android application in Qt 5.10. The application consists of a main.qml that holds a Qt StackView. In this StackView one Qt Flickable page is defined with a button on it to navigate to a new page, which is a Qt WebView. After navigation, this WebView will load a local HTML page. But when I hit the Android back button on the second page the app will not navigate back to the first one. See the code below for more information.

    main.qml

    import QtQuick 2.10
    import QtQuick.Controls 2.2
    
    ApplicationWindow {
        id: appWindow
        visible: true
    
        StackView {
            id: navPane
            anchors.fill: parent
            initialItem: pageOne
    
            Keys.onBackPressed: {
                popOnePage()
            }
    
            function popOnePage() {
                if(navPane.depth == 1)
                    return
                pop()
            }
    
            function pushOnePage(pageComponent) {
                push(pageComponent)
            }
        }
    
        Component {
            id: pageOne
            PageOne {}
        }
    
        Component {
            id: pageTwo
            PageTwo {}
        }
    }
    
    

    PageOne.qml

    import QtQuick 2.10
    import QtQuick.Controls 2.2
    
    Flickable {
    
        Button {
            text: "Go to page 2"
            anchors.centerIn: parent
    
            onClicked: {
                navPane.pushOnePage(pageTwo)
            }
        }
    }
    

    PageTwo.qml

    import QtQuick 2.10
    import QtWebView 1.1
    
    WebView {
        id: webView
        url: initialUrl //link to local HTML file
    }
    

    After some debugging I found out that the Keys.onBackPressed signal is never received. But when I use a Flickable instead of a WebView the signal will be received and the navigation works as expected. Can someone tell me if it is possible to receive this signal while using a WebView or maybe tell me what I am doing wrong? It will also do for me if there exists another component that can work with HTML. Any help would be greatly appreciated!

    1 Reply Last reply
    0

    1/1

    19 Mar 2018, 12:37

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved