Set background image after receiving signal
Solved
QML and Qt Quick
-
I have some code:
import QtQuick 2.9
ApplicationWindow {
id: mainWindow visible: true width: 1920 height: 1080 flags: Qt.FramelessWindowHint Image { id: nextView visible: false source: "ChargeView.png" } background: Image { id: loggingImage source: "LoggingView.png" } Loader { id: chargeViewLoader source: "ChargeViewItems.qml" } Connections { target: chargeViewLoader.item onCancelSignal: { mainWindow.background = nextView (*) console.log("Cancel"); } onOkSignal: console.log("OK"); } // any other code
}
signals cancelSignal and okSignal are received form another QML file.
When cancelSignal (line * ) is received I would like to change background image on mainWindow
but there is only white screen -
@Milosz Hi,
Change only the
source
property of yourloggingImage
component:ApplicationWindow{ //... background: Image { id: loggingImage source: "LoggingView.png" } Loader { id: chargeViewLoader source: "ChargeViewItems.qml" } Connections { target: chargeViewLoader.item onCancelSignal: { loggingImage.source = "ChargeView.png" console.log("Cancel"); } onOkSignal: console.log("OK"); } // any other code }