Connect action in QMainWindow with method of view's delegate (PySide/Qt/PyQt)

前端 未结 1 773
遇见更好的自我
遇见更好的自我 2020-12-21 14:45

I have a QTreeView displaying data from a QStandardItemModel. One of the columns of the tree is displayed with a delegate that lets the user edit a

相关标签:
1条回答
  • 2020-12-21 15:50

    I think from a design point of view the top window is a sort of global. You have already described a behaviour which is treating it in that way and (as ekhumoro has said) that pretty much requires you to provide access to that top window to the editor.

    One very simple way to do that is to call parent.window() in the createEditor method. Maybe something like:

    parent.window().boldTextAction.triggered.connect(editor.toggleBold)
    

    That seems to work for me.

    0 讨论(0)
提交回复
热议问题