Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-130100

Two QListView objects in QInputDialog

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 6.7.2
    • None
    • Linux/X11

    Description

      I'm using a QInputDialog with a list view instead of a combo box (rationale: makes it easier to see more/all available options at first look) to let the user choose a type from a list. For convenience a double click on an item immediately accepts this choice.

      This code worked fine and without surprises with PyQt5 to fill and perform the selection:

       

      typeSel = QInputDialog(self)
      
      typeSel.setWindowTitle(self.windowTitle())
      typeSel.setLabelText(self.tr("Select the type of the new account"))
      typeSel.setOption(QInputDialog.UseListViewForComboBoxItems)
      typeSel.setComboBoxItems(ACCOUNT_TYPE_TEXTS.values())
      typeSel.resize(typeSel.minimumSizeHint())
      typeSel.findChildren(QListView)[0].doubleClicked.connect(typeSel.accept)
      
      if typeSel.exec() != QInputDialog.Accepted:
          return
      
      [...]

      While porting my application to PyQt6 I noticed the double click didn't work anymore. I found that QInputDialog now contains two QListView objects; print(typeSel.findChildren(QListView)) shows this:

       

       

      [<PyQt6.QtWidgets.QListView object at 0x7f3615c8f4d0>, <PyQt6.QtWidgets.QListVie
      w object at 0x7f3615c8f6b0>] 

      Here is the adaption to the code above I came up with to fix the behaviour in Qt6:

       

      # There might be more than one listview object; listen to the last one added
      typeSel.findChildren(QListView)[-1].doubleClicked.connect(typeSel.accept) 

      I assume the two list view objects aren't really intended.

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            murphyde Martin Gebert
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes