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. Set background image after receiving signal
Forum Updated to NodeBB v4.3 + New Features

Set background image after receiving signal

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 614 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Milosz
    wrote on last edited by
    #1

    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

    Gojir4G 1 Reply Last reply
    0
    • M Milosz

      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

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @Milosz Hi,

      Change only the source property of your loggingImage 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
      }
      
      1 Reply Last reply
      3
      • M Offline
        M Offline
        Milosz
        wrote on last edited by
        #3

        It is great!!!
        Thanks a lot,

        Pablo J. RoginaP 1 Reply Last reply
        1
        • M Milosz

          It is great!!!
          Thanks a lot,

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @Milosz if your issue is solved, please don't forget to mark your post as such. Thanks.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          2

          • Login

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