PDA

View Full Version : Refreshing icon (decoration role) in a QListView



Marga
19th September 2011, 17:08
Hello all,

I have an application which has two custom QListViews, let's say "view1" and "view2". I have a fixed set of files which can be displayed by any of them.

When the application begins, all the files are in the folder displayed by view1. The user then can drag and drop the files from one view to the other, therefore there are two different behaviours:


If the user drags the files from view1 to view2, the file is copied to view2 (to the folder displayed by it in that given moment). And in view1, that file is displayed as disabled (the icon is greyed out).

If the user drags the files from view2 to view1, the file is deleted from view2 and the icon associated to the file in view1 is displayed again as enabled (with colours).


The problem I am experiencing is a glitch in the appearance of the icons. For example, when I drag an item from view1 to view2 (first behaviour described above), the icon does not appeared greyed out until I click somewhere in the window. I need that change to be visible immediately.

Is there a way to force the view to refresh?? I have tried update() and repaint() inside my custom dropEvent function (where the files get deleted, copied, etc.) but none of them work.

Thanks a million in advance!! I am really stuck with this :(

Marga.

Marga
21st September 2011, 09:38
Hi all,

I see nobody has a solution for me :( I have found a way to make this work, but I guess it's not very efficient...

I do:
hide();
show();

at the end of the dropEvent function of my custom QListView class and the view updates instantly.

I hope this helps someone!

Thanks!