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. Image disapear when charging
Forum Updated to NodeBB v4.3 + New Features

Image disapear when charging

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

    Hi,
    what i want to do is change image to do a simple animation, so i used a timer to do that but when you change source of Image, the time it is charging there is a quick white moment.
    I mean, normally the image should change only when it is loaded, so there would be always an Image seen, but when you change source to another one, then it flickers.
    Is there a way to avoid that ?
    Here is a code to illustrate that (i put cache: false like this u can see image is blank when it is charging else second time image is on cache so you can't see it).

    File Page1Form.ui.qml

    import QtQuick 2.7
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.0

    Item {
    property alias button1: button1
    property alias button2: button2
    property alias image: image

    RowLayout {
        anchors.centerIn: parent
    
        Button {
            id: button1
            text: qsTr("Press Me 1")
        }
    
        Button {
            id: button2
            text: qsTr("Press Me 2")
        }
    
        Image {
            id: image
            width: 223
            height: 159
            cache: false
            asynchronous: true
            source: ""
        }
    }
    

    }

    File Page1.qml

    import QtQuick 2.7

    Page1Form {
    button1.onClicked: {
    console.log("Button 1 clicked.");
    image.source="http://pngimg.com/upload/computer_pc_PNG7714.png"
    }
    button2.onClicked: {
    console.log("Button 2 clicked.");
    image.source="http://www.wiu.edu/academics/majors/business_and_technology/images/desktop_computer_512.png"
    }
    }

    Thanks
    Sincerely

    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