Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to clear or delete Image in QML
Qt 6.12 LTS is out! See what's new in the release blog

How to clear or delete Image in QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 1.8k 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.
  • nishiokasN Offline
    nishiokasN Offline
    nishiokas
    wrote on last edited by nishiokas
    #1

    Hello.
    How to clear or delete Image in QML?

    I'd like to make the application.
    it likes "slide show" application.

    example

    Image {
        id: mPicture
    }
    Timer {
        interval: 2000
        running: true
        repeat: true
        property var fList //it has many imagefile path ex. aaa.png, bbb.png...
        property int nextIdx
        onTriggered:{
            mPicture.source = "file://" + fList[nextIdx]
            nextIdx++
            if(fList.length <= nextIdx) {
                nextIdx = 0
            }
        }
    }
    

    It's working.
    but few minutes later application will down.
    I think I have to clear or delete mPicture.source.

    I already try it.

        mPicture.source = ""
        mPicture.source = "file://" + fList[nextIdx]
    

    But it's same.

    Could you let me know how should I do?
    thanks.

    J.HilkJ 1 Reply Last reply
    0
    • nishiokasN nishiokas

      Hello.
      How to clear or delete Image in QML?

      I'd like to make the application.
      it likes "slide show" application.

      example

      Image {
          id: mPicture
      }
      Timer {
          interval: 2000
          running: true
          repeat: true
          property var fList //it has many imagefile path ex. aaa.png, bbb.png...
          property int nextIdx
          onTriggered:{
              mPicture.source = "file://" + fList[nextIdx]
              nextIdx++
              if(fList.length <= nextIdx) {
                  nextIdx = 0
              }
          }
      }
      

      It's working.
      but few minutes later application will down.
      I think I have to clear or delete mPicture.source.

      I already try it.

          mPicture.source = ""
          mPicture.source = "file://" + fList[nextIdx]
      

      But it's same.

      Could you let me know how should I do?
      thanks.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @nishiokas most likly you indexing fList wrong and outrun the length.

      However I would suggest taking a look the the SlideShow-Example from the docs.

      That should help you more.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      0
      • nishiokasN Offline
        nishiokasN Offline
        nishiokas
        wrote on last edited by
        #3

        @J-Hilk
        Thanks for reply.
        I'm sorry I didn't take more information.
        "fList" has many image file.
        and the application is working.

        I would not big change to the application.
        I'd like to know how to clear image.

        Thanks for your help!

        1 Reply Last reply
        0
        • timdayT Offline
          timdayT Offline
          timday
          wrote on last edited by timday
          #4

          Simply updating the mPicture.source should be sufficient to release any resources consumed by the previously displayed image; there's no need for any additional code to explicitly "clear" it.

          What's the exact nature of "application will down"? Do you get an error message on the console? If it's a crash, where does a stack-trace say it crashes?

          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
          • Unsolved