what is the solution of TypeError: QTreeWidget.setModel() is a private method

后端 未结 1 950
情书的邮戳
情书的邮戳 2021-01-22 14:53

I am very new to Pyqt5 and am trying to build a GUI. I made a QtreeWidget under Qdockwidget.
When I try to set QFileSystemModel with <

相关标签:
1条回答
  • 2021-01-22 15:30

    The QTreeWidget only has a read-only model so you cannot replace it with another model, so in your case the error message tries to evidence it.

    The solution in your case is to change it to QTreeView:

    self.treeWidget_2 = QtWidgets.QTreeView(self.dockWidgetContents_5)

    In addition, you must also delete the following line of code:

    self.treeWidget_2.headerItem().setText(0, "1")
    
    0 讨论(0)
提交回复
热议问题