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. QTableView: openPersistentEditor doesn't resize
Forum Updated to NodeBB v4.3 + New Features

QTableView: openPersistentEditor doesn't resize

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 545 Views 1 Watching
  • 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.
  • B Offline
    B Offline
    beatreichenbach
    wrote on last edited by
    #1

    Hello,
    I'm finding that editors opened with openPersistentEditors do not resize until the resize action has stopped.

    Here's my code:

    from PySide2 import QtCore, QtGui, QtWidgets
    
    class Delegate(QtWidgets.QStyledItemDelegate):
        def createEditor(self, parent, option, index):
            editor = QtWidgets.QComboBox(parent)
            editor.addItems(map(str, range(5)))
    
            return editor
    
    class Main(QtWidgets.QMainWindow):
        def __init__(self, parent=None):
            super().__init__(parent)
    
            self.tableview = QtWidgets.QTableView()
            self.model = QtGui.QStandardItemModel()
            self.tableview.setModel(self.model)
            self.setLayout(QtWidgets.QVBoxLayout())
            self.layout().addWidget(self.tableview)
    
            items = []
            for i in range(5):
                item = QtGui.QStandardItem()
                items.append(item)
    
            self.model.appendRow(items)
            self.tableview.setItemDelegateForColumn(1, Delegate(self))
    
            self.tableview.openPersistentEditor(self.model.index(0, 1))
    
    if __name__ == '__main__':
        import sys
        app = QtWidgets.QApplication(sys.argv)
        main = Main()
        main.show()
        sys.exit(app.exec_())
    

    And here's a screenshot of what the combobox looks like when resizing the columns.
    screenshot.jpg

    I kept the example code as simple as possible, is there anything I'm missing?

    Thanks,
    Beat

    eyllanescE 1 Reply Last reply
    1
    • B beatreichenbach

      Hello,
      I'm finding that editors opened with openPersistentEditors do not resize until the resize action has stopped.

      Here's my code:

      from PySide2 import QtCore, QtGui, QtWidgets
      
      class Delegate(QtWidgets.QStyledItemDelegate):
          def createEditor(self, parent, option, index):
              editor = QtWidgets.QComboBox(parent)
              editor.addItems(map(str, range(5)))
      
              return editor
      
      class Main(QtWidgets.QMainWindow):
          def __init__(self, parent=None):
              super().__init__(parent)
      
              self.tableview = QtWidgets.QTableView()
              self.model = QtGui.QStandardItemModel()
              self.tableview.setModel(self.model)
              self.setLayout(QtWidgets.QVBoxLayout())
              self.layout().addWidget(self.tableview)
      
              items = []
              for i in range(5):
                  item = QtGui.QStandardItem()
                  items.append(item)
      
              self.model.appendRow(items)
              self.tableview.setItemDelegateForColumn(1, Delegate(self))
      
              self.tableview.openPersistentEditor(self.model.index(0, 1))
      
      if __name__ == '__main__':
          import sys
          app = QtWidgets.QApplication(sys.argv)
          main = Main()
          main.show()
          sys.exit(app.exec_())
      

      And here's a screenshot of what the combobox looks like when resizing the columns.
      screenshot.jpg

      I kept the example code as simple as possible, is there anything I'm missing?

      Thanks,
      Beat

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @beatreichenbach I do not reproduce the problem, try adding app.setStyle("fusion")

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        beatreichenbach
        wrote on last edited by
        #3

        That didn't fix the issue itself. I appended another gif of the issue. This happens both in "standalone" Qt and in a dcc such as maya.

        openPersistentEditor.gif

        eyllanescE 1 Reply Last reply
        0
        • B beatreichenbach

          That didn't fix the issue itself. I appended another gif of the issue. This happens both in "standalone" Qt and in a dcc such as maya.

          openPersistentEditor.gif

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by eyllanesc
          #4

          @beatreichenbach okay, that's not the error you were describing. Now with the .gif the error is better understood.

          what is your PySide2 version?

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            beatreichenbach
            wrote on last edited by
            #5

            I'm using the latest PySide2 package available through pip: https://pypi.org/project/PySide2 which is currently PySide2 5.15.2.

            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