Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. visibility problems with WebView and Image
Qt 6.11 is out! See what's new in the release blog

visibility problems with WebView and Image

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 238 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.
  • V Offline
    V Offline
    vcasado
    wrote on last edited by vcasado
    #1

    Hello,

    I have a view that must display a web page if there is connection to internet, or a text and an image if it doesn't.

    for that I have the following QML:

    import QtQuick
    import QtQuick.Controls
    import QtQuick.Layouts
    import QtWebView
    
    Rectangle {
        id: contactoPage
        anchors.fill: parent
        color: "#000000"
    
        Rectangle
        {
            id: contactoName
            color: "#000000"
            anchors.top: parent.top
            height: parent.height / 9
            width: parent.width
    
            Label
            {
                text: qsTr("Contact")
                color: "white"
                font.pointSize: 25
                anchors.centerIn: parent
                font.family: helvetica.font.family
                font.weight: helvetica.font.weight
            }
    
            Image {
                anchors.verticalCenter: parent.verticalCenter
                x : 40
                height: parent.height * 0.3
                width: height
                source: "qrc:/images/backarrow.png"
    
                MouseArea
                {
                    anchors.fill: parent
                    onClicked: {
                        showPage("Settings.qml");
                    }
                }
            }
        }
    
        Rectangle
        {
            id: contactobackground
            color: "#000000"
            anchors.top: contactoName.bottom
            anchors.bottom: parent.bottom
            width: parent.width * 0.9
            anchors.centerIn: parent
    
            WebView {
                id: webView
                anchors.fill: parent
                visible: m_bleInterface.checkInternetConnection() ? true : false
                url: "https://google.com/"
            }
    
            Text {
                id: legalText
                visible: m_bleInterface.checkInternetConnection() ? false : true
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.top: parent.top
                height: parent.height * 0.3
                wrapMode: Text.WordWrap
                color: "#FFFFFF"
                textFormat: Text.RichText
                font.family: helvetica.font.family
                font.weight: helvetica.font.weight
                horizontalAlignment: Text.AlignLeft
                text: qsTr("Some Text")
                onLinkActivated: Qt.openUrlExternally(link)
            }
    
            Image {
                anchors.top: legalText.bottom
                visible: m_bleInterface.checkInternetConnection() ? false : true
                height: parent.height * 0.3
                width: height * (1080 / 766)
                source: "qrc:/images/Images_contacto.png"
            }
    
    
        }
    }
    
    

    The m_bleInterface.checkInternetConnection() method works correctly.
    The problem that I have, is that when there is connection, no webpage is shown (the screen is black) and when there is no connection, the text is shown but the image doesn't.

    In my main.cpp I have:

    ...
            QGuiApplication app(argc, argv);
            QtWebView::initialize();
    ...
    

    Can anyone help me, please?

    Thank you,
    Best regards

    1 Reply Last reply
    0

    • Login

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