By default, editing an item in a QTable selects all the text within the cell. I want to avoid that. However, I cannot seem to find where this happens.
I wrote a simple custom Delegate which inherits from QStyledItemDelegate, and returns a custom object which simply inherits from a QLineEdit. In these classes, I tried some combinations of what I thought could do the “trick”, such as disabling QLineEdit::focusInEvent(), specifying the selection of my QLineEdit, but nothing works.
The closest I get is that when I click a cell, I set the selected text I want. But between the moment when the cell is clicked, and the moment when my custom selection is performed, the whole text is selected anyway, which I want to avoid.
Any idea? Thanks,
Coding a custom QLineEdit like this:
and setting it as editor widget, I can double-click the table cell and obtain a line edit with some pre-selected text without any flickering. Anyway, the entire cell becomes selected in the middle of double-clicking, don’t know if this is acceptable for you.