Details
-
Bug
-
Resolution: Unresolved
-
P4: Low
-
None
-
6.7.2
-
None
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.