Results 1 to 7 of 7

Thread: how to repaint the custom delegate

  1. #1
    Join Date
    Jun 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default how to repaint the custom delegate

    hi:
    i have a listview with custom delegate and model. i want a checkbox in each row,and click the checkbox or the row will lead to different functions. i do not know how to handle this.but i found a method to handle it. i use a bool to determine whether to draw checkbox or not.this codes were written in QAbstractItemDelegate:aint.and a button to decide the bool's value.
    so here comes the problem,when i click the button,the checkbox did not show.when i move my mouse,it will appear.so i know i should send some singals or somethings to trigger the checkbox show.but i do not know ,how to do that things.please help me.thankx.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to repaint the custom delegate

    Do you really need custom delegate ? You could have used QListWidgetItem and QListWidgetItem::setCheckState .

    Still hard to help you without seeing some code.

  3. #3
    Join Date
    Jun 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to repaint the custom delegate

    thanks for you reply.
    i do need use custom delegate. my list view is like that.
    QQ截圖20120621105615.png
    the code works fine and have noting to do with the problem i asked. i want to improve the performance,so i encounter that problem.when i click the edit button, i change a bool value in the subclass of QAbstractItemDelegate,and in the function paint.
    QQ截圖20120621110217.jpg
    QQ截圖20120621110334.jpg
    when i move my mouse ,the paint will be called and the checkbox will showed in the list.
    but now i want to automatic repaint the listview ,not the movement of my mouse will activate it.so please help me, how to do that thing.
    Attached Images Attached Images

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to repaint the custom delegate

    Did you try QListView::update or QListView::repaint when the Edit button is clicked ?

  5. #5
    Join Date
    Jun 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to repaint the custom delegate

    i had tried QListIView::repaint, it no works. but QListView::update need a QModelIndex, and i do not know how to make one.so it is still stuck. and do you know how to send out the mouse movement event,if we know that,this problem will be solved.

  6. #6
    Join Date
    Jun 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to repaint the custom delegate

    i found a special method to solve this problem. when i clicked the button,i call a function in delegate,which emit dataChanged signal.thus the paint function in model will be called and my checkbox will show in the frame.

  7. #7
    Join Date
    Jul 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to repaint the custom delegate

    hi yuyue,
    can you explain and/or post your solution, because I have the same kind of issue with my paint update from my delegate ?

    Best Regards.
    Domzique.
    Ok I find a way to repaint using
    Qt Code:
    1. view->setFocus()
    To copy to clipboard, switch view to plain text mode 
    Last edited by domzique; 17th August 2012 at 20:51.

Similar Threads

  1. Custom Model? Custom View? Custom Delegate?
    By Doug Broadwell in forum Newbie
    Replies: 4
    Last Post: 11th February 2010, 21:23
  2. Replies: 0
    Last Post: 1st February 2010, 12:00
  3. Question about custom view (or custom delegate)
    By skuda in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2009, 21:06
  4. Replies: 0
    Last Post: 28th August 2009, 10:49
  5. Replies: 1
    Last Post: 13th July 2006, 22:10

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.