Results 1 to 3 of 3

Thread: QItemDelegate problem

  1. #1
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QItemDelegate problem

    I have a QWidget that displays a series of image thumbnails. The thumbnails appear as image boxes in a grid pattern.

    The thumbnails are drawn by a custom QItemDelegate. It draws a box and an image. Now, according to the customer's spec, when the cursor is moved over a thumbnail, a little "X" delete button has to appear on that specific thumbnail. So the itemDelegate's paint() method checks the QStyleOptionViewItem argument, checking for QStyle::State_MouseOver. If that flag is there, it draws the "X" delete button.

    That is working perfectly.

    Here is the problem.

    Say you have a row of thumbnails A, B, C, D and E. You move the cursor over C. The X delete button appears. You click the delete button. Thumbnail C vanishes.

    Now, the remaining thumbnails move over to close the gap, so you have A, B, D, and E. The cursor has not move, but it is now over thumbnail D.

    The bug is, the X delete button does NOT appear, since the mouse has not moved. True, it appears the instant the mouse is moved, but the customer is not pleased.

    I am unsure as to the best way of dealing with this. I tried doing a reset() on the model, but of course that did nothing. That won't set the QStyle::State_MouseOver on the appropriate itemDelegate.

    Any suggestions?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QItemDelegate problem

    The problem is not with the delegate. If you want, you might post the event to the view yourself.

  3. The following user says thank you to wysota for this useful post:

    WinchellChung (5th December 2007)

  4. #3
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: QItemDelegate problem

    Thanks, wysota. Boy do I feel stupid.

Similar Threads

  1. premature call to setmodeldata with QItemDelegate
    By placebo in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2007, 17:39
  2. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  3. [QMYSQL] connection problem
    By chaos_theory in forum Installation and Deployment
    Replies: 5
    Last Post: 2nd July 2007, 09:52
  4. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.