Discussion:
[Interest] What is the best way to refresh QML image
Harri Pasanen
2015-03-10 10:26:09 UTC
Permalink
Hi,

Is there a way to force QML image to refresh, other than changing its
"source" property?

Thanks,

Harri
Daniel França
2015-03-10 10:34:21 UTC
Permalink
What exactly you want to do?
Post by Harri Pasanen
Hi,
Is there a way to force QML image to refresh, other than changing its
"source" property?
Thanks,
Harri
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
Harri Pasanen
2015-03-10 10:47:39 UTC
Permalink
Exactly: I want QML Image to have a refresh() method that will force it
to reload the image.

One use case: let's say I have a jpg on disk that I'm showing in QML.
If I edit the image in an external application and save it again with
the same name,
I'd like to be able to reload the image without changing the source name.



Harri
Post by Daniel França
What exactly you want to do?
Hi,
Is there a way to force QML image to refresh, other than changing its
"source" property?
Thanks,
Harri
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
Daniel França
2015-03-10 10:49:59 UTC
Permalink
So I think this discussion can help you:
http://forum.qt.io/topic/6935/how-to-reload-an-image-in-qml/3
Post by Harri Pasanen
Exactly: I want QML Image to have a refresh() method that will force it
to reload the image.
One use case: let's say I have a jpg on disk that I'm showing in QML.
If I edit the image in an external application and save it again with the
same name,
I'd like to be able to reload the image without changing the source name.
Harri
What exactly you want to do?
Post by Harri Pasanen
Hi,
Is there a way to force QML image to refresh, other than changing its
"source" property?
Thanks,
Harri
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
Harri Pasanen
2015-03-10 13:52:48 UTC
Permalink
Well, reading the thread it seems that options are:
1. changing the "source" property, which feels like a hack if used directly.
2. setting cache=false and calling sourceChanged(), but it was not clear
from the thread if this works or not.
3. implementing a custom item to replace Image, which feels like an
overkill for this.

I ended up writing a NameStore in C++ which serves the names used for
"source" and can then redirect those as I wish. It is convenient in
that it act as a central broker, "touching" an image will cause all
linked Image elements to update.

Regards,

Harri
Post by Daniel França
http://forum.qt.io/topic/6935/how-to-reload-an-image-in-qml/3
Exactly: I want QML Image to have a refresh() method that will
force it to reload the image.
One use case: let's say I have a jpg on disk that I'm showing in QML.
If I edit the image in an external application and save it again
with the same name,
I'd like to be able to reload the image without changing the source name.
Harri
Post by Daniel França
What exactly you want to do?
Em ter, 10 de mar de 2015 às 11:26, Harri Pasanen
Hi,
Is there a way to force QML image to refresh, other than changing its
"source" property?
Thanks,
Harri
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
VStevenP
2015-03-10 17:32:35 UTC
Permalink
Hi Harry,

If you want a low-tech, QML-only workaround, perhaps you could have 2 Images at the same location with the same dimensions, and just switch between them when a refresh occurs.

You could stage the refreshed picture into the currently invisible, source-less Image, then set it to visible, then on the other Image you could set visible to false and source string to a null string. You could also swap the Images z values at this time, to make the currently invisible one always be "behind" the currently visible one. That would avoid any flicker during the switching between Images.

I'm thinking this is probably not so inefficient, because most of the time, only one Image would be visible.

- VStevenP
Steve Pavao
Korg R&D

----

Message: 3
Date: Tue, 10 Mar 2015 11:47:39 +0100
From: Harri Pasanen <***@mpaja.com>
Subject: Re: [Interest] What is the best way to refresh QML image
To: Daniel Fran?a <***@gmail.com>, "***@qt-project.org"
<***@qt-project.org>
Message-ID: <***@mpaja.com>
Content-Type: text/plain; charset="utf-8"

Exactly: I want QML Image to have a refresh() method that will force it
to reload the image.

One use case: let's say I have a jpg on disk that I'm showing in QML.
If I edit the image in an external application and save it again with
the same name,
I'd like to be able to reload the image without changing the source name.
Loading...