Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QTreeView initiates editing due to other triggers than the one configured, why?

    General and Desktop
    1
    2
    636
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      aknudsen last edited by

      I'm having the problem that the "edit":http://qt-project.org/doc/qt-5/qabstractitemview.html#edit-2 method of QTreeView is getting called due to other triggers than the one I have enabled, which is "SelectedClicked":http://qt-project.org/doc/qt-5/qabstractitemview.html#EditTrigger-enum. Why does this happen?

      Below is an example of what I'm doling, if you try it you should see that edit gets called due to different triggers:

      @
      from PyQt5.QtCore import *
      from PyQt5.QtWidgets import *
      from PyQt5.QtGui import *

      class TreeView(QTreeView):
      def init(self):
      super().init()
      self.setEditTriggers(self.SelectedClicked)

          self.__model = QStandardItemModel()
          self.__model.appendRow([QStandardItem('Item 1')])
          self.__model.appendRow([QStandardItem('Item 2')])
          self.setModel(self.__model)
      
      def edit(self, index, trigger, event):
          print('Edit index {},{}, trigger: {}'.format(index.row(), index.column(), trigger))
          return False
      

      app = QApplication([])
      w = TreeView()
      w.show()
      app.exec_()
      @

      See also "my SO question":http://stackoverflow.com/questions/27169261/why-does-editing-in-qtreeview-get-initiated-by-other-triggers-than-the-one-i-hav on this topic.

      1 Reply Last reply Reply Quote 0
      • A
        aknudsen last edited by

        Nevermind, I got an elucidating "answer":http://stackoverflow.com/a/27172458/265261.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post