Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTreeView initiates editing due to other triggers than the one configured, why?

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 713 Views
  • 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 Offline
    A Offline
    aknudsen
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      aknudsen
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved