Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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":http://qt-project.org/doc/qt-5/qtwidgets-itemviews-stardelegate-example.html, 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;

    view->setMouseTracking(true);

    emit sizeHintChanged to force view to repaint when needed;

    I got similar things with "star delegate example":http://qt-project.org/doc/qt-5/qtwidgets-itemviews-stardelegate-example.html, 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