Get key modifiers when editting QAbstractItemModel
-
Why not simply use QGuiApplication::keyboardModifiers()?
-
QGuiApplication::keyboardModifiers()? is a good idea.
I have just used it in my setData function of QAbstractItem model and it works see hereunder picture: -
Thanks for all your replies.
SGaist - my use case is the following one : columns are index of a list of objects in my model and lines are different properties of these objects. When modifying a cell with CTRL key pressed, I would like to modify the same propery (corresponding to the editted line number) of all objects with the same value. If not pressed, I only modify the property of the object with current column index. I hope my explanation is clear enough. I am interested if there is a cleaner way to get this kind of mechanism.
Christian Ehrlicher/Slawomir_Piernikowski - It seems to answer my issue, I did not know well QGuiApplication class. Thanks for your answer, I will try it tomorrow !
-
I'd rather implement that at the view level. Otherwise you might have strange behaviours if your model is used through another view or if
setData
is called from somewhere else than your current view. -
What kind of editor are you using ?
-
Then one possibility would be to implement a custom QStyledItemDelegate and reimplement setModelData.