Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] QItemDelegate and complex editor widgets loosing focus



  • My subclass of QItemDelegate is providing complex editor widgets to a QTableView. One example of my problem is a QTreeView editor that looses focus and completes the edit when it's contextMenuEvent is triggered.

    What would be the best design to only allow my editor widgets to complete when a button within the editor is pushed? What event would this button trigger and how would I prevent the editors to loose focus?

    Many thanks.



  • SOLVED: The reason the editor widget was loosing focus was because the QMenu object that was being created during the contextMenuEvent was not being constructed with a parent object defined.

    @c_menu = QtGui.QMenu(self)@

    This ensures the editor widget maintains focus when the context menu is created.


Log in to reply