QQuickItem::grabToImage - Image created using grabToImage is not getting refreshed in the device for the first time
-
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?
-
@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. -
@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? -
@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.
-
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