Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QTableview index issue
Using PyQt5, one feature of my application is that there is a QTableView that dynamically increases the number of rows it has. Each column has a different purpose, widgets, text entries, etc. One such columns has QComboBoxes with 3-4 entries (but potentially more in the future). What I want to be able to do is when the user selects one of the indices from the combo box, I want the adjacent cell (same row, different column) text entry to be disabled. The problem is that all of the signals from QComboBox point to the index of the item selected in the combo box itself, so I have no way of knowing which row (in the whole table) is selected, therefore after I determine which index in the combo box was changed (with currentIndexChanged), I don't know which row in the table to apply the change to. Because there is a dynamic number of rows, I can't just make a new signal for each new row. Any help would be appreciated.
VRonin last edited by
QStyledItemDelegateto use a combobox and set that delegate to the column you want. then conncet to the
dataChangedsignal of your model and if the changed index is in the column with the combos decide what to do
Thank you so much.
On and unrelated question, when setting flags, for instance ".setFlags(QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsSelectable)" and "setFlags(content.flags() & ~QtCore.Qt.ItemIsEditable & ~QtCore.Qt.ItemIsSelectable)" , are the | and & characters acting like logical ORs and ANDs? Like does it take the current value of of the flags and use that to compute the values of all of them? For instance, in the first example, if currently ItemIsEditable is true and the ItemIsSelectable is false, would it set them both to true b/c they're ORed?
Yes its OR AND , NOT (negate)
( i assume its the same for python as for c++ :)
setFlags(QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsSelectable)
setFlags(content.flags() & ~QtCore.Qt.ItemIsEditable & ~QtCore.Qt.ItemIsSelectable
Take current flags and mask out both ItemIsEditable and ItemIsSelectable
VRonin last edited by
They are bitwise operators AND/OR