-
Bug
-
Resolution: Cannot Reproduce
-
Not Evaluated
-
None
-
5.14.0, 5.15.2
-
None
-
Linux Raspberry Pi 6.1.21-v8+ aarch64 GNU/Linux (ARM)
Ubuntu 20.04 x86_64
Please find attached example to reproduce the bug.
I have two comboboxes, one refreshing the other, and the other has some greyed-out items.
I also have an event filter declared (doing nothing).
My main program is:
import sys
from PySide2.QtWidgets import QApplication
from dialog import Dialog
class App(QApplication):
def }}{{{}__{}init__{}(self, sys_argv):
super(App, self).__{}init__{}(sys_argv)
self.main_view = Dialog()
self.main_view.show()
def eventFilter(self, obj, event):
return super(App, self).eventFilter(obj, event)
if }}{{{}__{}name__ {}{}== "__{}main__{}":
app = App(sys.argv)
app.installEventFilter(app)
sys.exit(app.exec_())
Code of my Dialog is:
from PySide2.QtWidgets import QDialog
from dialog_ui import Ui_Dialog
class Dialog(QDialog):
def }}{{{}__i{}nit__{}(self):
super().__{}init__({})
self._ui = Ui_Dialog()
self._ui.setupUi(self)
self._ui.comboBox1.currentIndexChanged.connect(self.comboBox1_indexChanged_slot)
def comboBox1_indexChanged_slot(self, index):
self._ui.comboBox2.clear()
skip = False
for index in range(100):
self._ui.comboBox2.addItem(f"{index}")
if skip:
self._ui.comboBox2.model().item(index).setEnabled(False)
skip = not skip
and code of the form is:
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
class Ui_Dialog(object):
def setupUi(self, Dialog):
self.horizontalLayout = QHBoxLayout(Dialog)
self.comboBox1 = QComboBox(Dialog)
self.comboBox1.setObjectName(u"comboBox1")
self.comboBox1.addItem("element1")
self.comboBox1.addItem("element2")
self.horizontalLayout.addWidget(self.comboBox1)
self.comboBox2 = QComboBox(Dialog)
self.comboBox2.setObjectName(u"comboBox2")
self.horizontalLayout.addWidget(self.comboBox2)
QMetaObject.connectSlotsByName(Dialog)
The Dialog form only contains the two combo boxes, first one with 2 items (code generated by pyqt).
I see a strange behaviour: after several alternative changes on the two combo boxes, I have this:
Traceback (most recent call last):
File "./bug_combo_box.py", line 13, in eventFilter
return super(App, self).eventFilter(obj, event)
TypeError: 'PySide2.QtCore.QObject.eventFilter' called with wrong argument types:
PySide2.QtCore.QObject.eventFilter(Dialog, QStandardItem)
Supported signatures:
PySide2.QtCore.QObject.eventFilter(PySide2.QtCore.QObject, PySide2.QtCore.QEvent)
What is happening? Memory corruption? What is strange is that it is always the same error, with only first parameter (here, `Dialog`, which is my main QDialog) changed (I have seen also App or QFrame).
Second parameter is always a `QStandardItem`, which has no sense (only events inheriting from QEvent expected here).
If I remove the `self._ui.comboBox2.model().item(index).setEnabled(False)` line, no more bug.
If I remove the event filter, no more bug.
What is wrong?
Please find attached example to reproduce the bug.
- relates to
-
PYSIDE-3143 QComboBox.model().item() causes crash when used eventFilter
-
- Closed
-