Results 1 to 2 of 2

Thread: Refreshing icon (decoration role) in a QListView

  1. #1
    Join Date
    Sep 2011
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Refreshing icon (decoration role) in a QListView

    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:

    1. 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).
    2. 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.

  2. #2
    Join Date
    Sep 2011
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Refreshing icon (decoration role) in a QListView

    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!

Similar Threads

  1. Line Decoration in QListView
    By fruzzo in forum Qt Programming
    Replies: 2
    Last Post: 15th September 2011, 15:56
  2. QListView + QStyledItemDelegate + text besides icon
    By NoRulez in forum Qt Programming
    Replies: 8
    Last Post: 1st February 2011, 22:06
  3. Icon margin in QListView
    By mpi in forum Qt Programming
    Replies: 4
    Last Post: 1st July 2010, 14:56
  4. icon glitch in QListView
    By trhaynes in forum Qt Programming
    Replies: 1
    Last Post: 31st August 2009, 20:48
  5. View decoration role empty on Windows
    By sebr in forum Qt Programming
    Replies: 5
    Last Post: 28th October 2007, 11:44

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.