Set initial text when editing a QTableView cell
Asked Answered
A

1

7

I've subclassed QAbstractTableModel and overrode the flags() method so that some of the table cells are editable. The problem is that when I start editing, the existing cell value is erased. I would like to initially have the existing cell value selected. How can I do this?

Aram answered 8/5, 2010 at 5:15 Comment(0)
A
12

The solution is to handle Qt::EditRole when overriding data(). I was previously only handling Qt::DisplayRole.

Aram answered 8/5, 2010 at 12:11 Comment(1)
You could also use a delegate and set it in setEditorData.Raft

© 2022 - 2024 — McMap. All rights reserved.