Qt 6.11 is out! See what's new in the release
blog
visibility problems with WebView and Image
-
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