Image not loading
-
Hi,
I am using Qt 6.5.0 and Qt Creator with Ubuntu. I am developing an interface for smart watch. So I was loading a background in it, but it seems not to loadHere is my QML code:
import QtQuick import QtQuick.Window import QtQuick.Layouts 1.15 import QtQuick.Controls 2.15 Window { width: 240 height: 240 visible: true color: "transparent" maximumHeight: 240 maximumWidth: 240 minimumHeight: 240 minimumWidth: 240 Rectangle{ id: circular_area height: parent.height width: parent.width radius: parent.width / 2 color: "black" } SwipeView{ id: swipe_view height: parent.height width: parent.width clip: true Item{ id: home_screen Image { id: wallpaper anchors.fill: parent source: "qrc:/images/arcs.png" fillMode: Image.PreserveAspectFit } ColumnLayout{ id: content_layout anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.right: parent.right spacing: 5 Text{ id: time color: "#ffffff" text: "16:00" font.pointSize: 20 font.weight: Font.DemiBold font.family: "Roboto" Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter } Text{ id: day color: "#ffffff" font.weight: Font.ExtraLight font.family: "Robot" Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter } Timer{ interval: 500 running: true repeat: true onTriggered: { var date = new Date() time.text = date.toLocaleTimeString(Qt.locale("en_IN"), "hh:mm") const days = ["Sunday", "Monday", "Tuesday", "Wednessday", "Thursday", "Friday", "Saturday"] let dayIndex = date.getDay() day.text = days[dayIndex] } } } } Item{ } } }Please help me out
Thanks in advance -
Hi,
I am using Qt 6.5.0 and Qt Creator with Ubuntu. I am developing an interface for smart watch. So I was loading a background in it, but it seems not to loadHere is my QML code:
import QtQuick import QtQuick.Window import QtQuick.Layouts 1.15 import QtQuick.Controls 2.15 Window { width: 240 height: 240 visible: true color: "transparent" maximumHeight: 240 maximumWidth: 240 minimumHeight: 240 minimumWidth: 240 Rectangle{ id: circular_area height: parent.height width: parent.width radius: parent.width / 2 color: "black" } SwipeView{ id: swipe_view height: parent.height width: parent.width clip: true Item{ id: home_screen Image { id: wallpaper anchors.fill: parent source: "qrc:/images/arcs.png" fillMode: Image.PreserveAspectFit } ColumnLayout{ id: content_layout anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.right: parent.right spacing: 5 Text{ id: time color: "#ffffff" text: "16:00" font.pointSize: 20 font.weight: Font.DemiBold font.family: "Roboto" Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter } Text{ id: day color: "#ffffff" font.weight: Font.ExtraLight font.family: "Robot" Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter } Timer{ interval: 500 running: true repeat: true onTriggered: { var date = new Date() time.text = date.toLocaleTimeString(Qt.locale("en_IN"), "hh:mm") const days = ["Sunday", "Monday", "Tuesday", "Wednessday", "Thursday", "Friday", "Saturday"] let dayIndex = date.getDay() day.text = days[dayIndex] } } } } Item{ } } }Please help me out
Thanks in advanceItem{ id: home_screen Image { id: wallpaper anchors.fill: parent source: "qrc:/images/arcs.png" fillMode: Image.PreserveAspectFit }Your
home_screenitem does not have dimensions (widthandheight) so in yourImagethe call toanchors.fill: parentdoes nothing. So your image is there but it spans 0x0 pixels.Plus, with QRC it's always tricky, so make sure the path is correct and also try other URLs like
:/images/arcs.pngorqrc://images/arcs.png. -
Hi,
I am using Qt 6.5.0 and Qt Creator with Ubuntu. I am developing an interface for smart watch. So I was loading a background in it, but it seems not to loadHere is my QML code:
import QtQuick import QtQuick.Window import QtQuick.Layouts 1.15 import QtQuick.Controls 2.15 Window { width: 240 height: 240 visible: true color: "transparent" maximumHeight: 240 maximumWidth: 240 minimumHeight: 240 minimumWidth: 240 Rectangle{ id: circular_area height: parent.height width: parent.width radius: parent.width / 2 color: "black" } SwipeView{ id: swipe_view height: parent.height width: parent.width clip: true Item{ id: home_screen Image { id: wallpaper anchors.fill: parent source: "qrc:/images/arcs.png" fillMode: Image.PreserveAspectFit } ColumnLayout{ id: content_layout anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.right: parent.right spacing: 5 Text{ id: time color: "#ffffff" text: "16:00" font.pointSize: 20 font.weight: Font.DemiBold font.family: "Roboto" Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter } Text{ id: day color: "#ffffff" font.weight: Font.ExtraLight font.family: "Robot" Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter } Timer{ interval: 500 running: true repeat: true onTriggered: { var date = new Date() time.text = date.toLocaleTimeString(Qt.locale("en_IN"), "hh:mm") const days = ["Sunday", "Monday", "Tuesday", "Wednessday", "Thursday", "Friday", "Saturday"] let dayIndex = date.getDay() day.text = days[dayIndex] } } } } Item{ } } }Please help me out
Thanks in advance@Raghav said in Image not loading:
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15import QtQuick.Layouts 1.15 <=version number is dropped in Qt6 import QtQuick.Controls 2.15 <=version number is dropped in Qt6 simply import QtQuick.Layouts import QtQuick.Controls