Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for MCUs
  4. QQuickItem::grabToImage - Image created using grabToImage is not getting refreshed in the device for the first time
Forum Updated to NodeBB v4.3 + New Features

QQuickItem::grabToImage - Image created using grabToImage is not getting refreshed in the device for the first time

Scheduled Pinned Locked Moved Solved Qt for MCUs
6 Posts 2 Posters 1.1k 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.
  • P Offline
    P Offline
    Pavankumar S V
    wrote on 21 Jul 2022, 05:24 last edited by Pavankumar S V
    #1

    Hello,

    I'm working on a QT project in my Company. We have our own devices and I'm working on creating user Interfaces on the display of our device. We have many qml files to create some objects which needs to displayed on the device.

    We have a Software Tool which draws the objects on the PC using qml Files as per the user settings(like the size, position of the object on the display etc..). Then the objects are downloaded into our device.

    I'm creating a Circular Gauge object in the Software Tool. The tool draws the image using qml and also takes a screenshot of the Circular Gauge using "grabToImage", and saves it into a file using "saveToFile". This file is used in the device to display the object directly(instead of drawing which takes time).

    Issue:
    The objects created in the Software tool are then downloaded into the device. As soon as I download, the image that is displayed on the device is not the latest. Instead it is showing the previously updated image. But when I restart the device or restart the application, then the image of the object is getting refreshed.
    Note: The image object is created dynamically.

    What is the reason for this issue? Is this related to grabToImage functionality?

    J 1 Reply Last reply 21 Jul 2022, 05:28
    0
    • P Pavankumar S V
      21 Jul 2022, 05:24

      Hello,

      I'm working on a QT project in my Company. We have our own devices and I'm working on creating user Interfaces on the display of our device. We have many qml files to create some objects which needs to displayed on the device.

      We have a Software Tool which draws the objects on the PC using qml Files as per the user settings(like the size, position of the object on the display etc..). Then the objects are downloaded into our device.

      I'm creating a Circular Gauge object in the Software Tool. The tool draws the image using qml and also takes a screenshot of the Circular Gauge using "grabToImage", and saves it into a file using "saveToFile". This file is used in the device to display the object directly(instead of drawing which takes time).

      Issue:
      The objects created in the Software tool are then downloaded into the device. As soon as I download, the image that is displayed on the device is not the latest. Instead it is showing the previously updated image. But when I restart the device or restart the application, then the image of the object is getting refreshed.
      Note: The image object is created dynamically.

      What is the reason for this issue? Is this related to grabToImage functionality?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 21 Jul 2022, 05:28 last edited by
      #2

      @Pavankumar-S-V said in QQuickItem::grabToImage - Image created using grabToImage is not getting refreshed in the device for the first time:

      Is this related to grabToImage functionality?

      I don't think so. You also can easilly verify whether you're uploading latest image to the device.
      You need to explain how you're showing these images on the device. Uploading new version of the image will not lead to a refresh in your application on the device without you writing code for doing so.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply 21 Jul 2022, 05:38
      0
      • J jsulm
        21 Jul 2022, 05:28

        @Pavankumar-S-V said in QQuickItem::grabToImage - Image created using grabToImage is not getting refreshed in the device for the first time:

        Is this related to grabToImage functionality?

        I don't think so. You also can easilly verify whether you're uploading latest image to the device.
        You need to explain how you're showing these images on the device. Uploading new version of the image will not lead to a refresh in your application on the device without you writing code for doing so.

        P Offline
        P Offline
        Pavankumar S V
        wrote on 21 Jul 2022, 05:38 last edited by
        #3

        @jsulm :
        Thanks for the response.
        I have checked the image stored in the device. It is the updated one. So the updated image is getting downloaded into the device.

        Code used by the device to display the image(This code is written inside the parent rectangle "clscMtrRect"):

        bkImage = Qt.createQmlObject('import QtQuick 2.9;
        Image
        {
        anchors.fill: clscMtrRect
        source: ticksImage
        z:5
        }
        ',clscMtrRect);

        So the updated image is stored in the path of "ticksImage" variable every time when we download the image. So the device runs this code every time and it is supposed to take the image from the path of "ticksImage".
        Is this not sufficient? Do you feel any extra code is required here to refresh the image?

        J 1 Reply Last reply 21 Jul 2022, 05:41
        0
        • P Pavankumar S V
          21 Jul 2022, 05:38

          @jsulm :
          Thanks for the response.
          I have checked the image stored in the device. It is the updated one. So the updated image is getting downloaded into the device.

          Code used by the device to display the image(This code is written inside the parent rectangle "clscMtrRect"):

          bkImage = Qt.createQmlObject('import QtQuick 2.9;
          Image
          {
          anchors.fill: clscMtrRect
          source: ticksImage
          z:5
          }
          ',clscMtrRect);

          So the updated image is stored in the path of "ticksImage" variable every time when we download the image. So the device runs this code every time and it is supposed to take the image from the path of "ticksImage".
          Is this not sufficient? Do you feel any extra code is required here to refresh the image?

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 21 Jul 2022, 05:41 last edited by
          #4

          @Pavankumar-S-V I'm not a QML expert, but I don't think that QML will automatically update the shown image when the image file changes. I'm sure QML loads the image once the code is executed. But as I said I'm not a QML expert, maybe somebody else can provide more information on this.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          P 1 Reply Last reply 21 Jul 2022, 05:50
          0
          • J jsulm
            21 Jul 2022, 05:41

            @Pavankumar-S-V I'm not a QML expert, but I don't think that QML will automatically update the shown image when the image file changes. I'm sure QML loads the image once the code is executed. But as I said I'm not a QML expert, maybe somebody else can provide more information on this.

            P Offline
            P Offline
            Pavankumar S V
            wrote on 21 Jul 2022, 05:50 last edited by
            #5

            @jsulm I confirmed that this code is running every time by using console prints. But still the image on the device is not getting refreshed.
            Thank you

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Pavankumar S V
              wrote on 25 Jul 2022, 04:21 last edited by
              #6

              The Root cause for this issue:
              "Cache" is a property of Image Object and its default value is true.
              So the image was not taken from the path given in the "source".
              When the value of "Cache" is changed to false, the issue is solved.
              Thank you

              1 Reply Last reply
              1

              1/6

              21 Jul 2022, 05:24

              • Login

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