Important: Please read the Qt Code of Conduct -

How to implement the editor directly in the delegate?

  • Hi All:
    I am a newbie of Qt and I am learning the "star delegate example":, I do not understand that "By reimplementing QAbstractItemDelegate::editorEvent(), it is possible to implement the editor directly in the delegate, instead of creating a separate QWidget subclass." at the end of "Possible Extensions and Suggestions". Can anyone please show me how to implement it? Thanks very much.

  • After some more testing, I found that by doing fallowing things:

    some code of starEditor mouseMoveEvent ---> delegate editorEvent and event->type== QMouseEvent::mouseMove;

    some code of StarRating paint ----> delegate paint;


    emit sizeHintChanged to force view to repaint when needed;

    I got similar things with "star delegate example":, but I can't exit the Eitable mode, because I can't detect when mouse leaving the item. Any help would be appreciate. And sorry for my poor English.

Log in to reply