On Fri, Aug 15, 2014 at 1:59 PM, Mark Gaiser <mark...@gmail.com> wrote: > Hi, > > I have a QTableView with data from a custom QSqlQueryModel. > So far so good, data displays just fine. > > I'm searching for functionality to select text in any column as if the > flag: Qt::ItemIsEditable is set. However, setting that also allows the > user to edit (type) in the field which is not what i want. > > As an example, if you set readonly to true on a QLineEdit you get the > exact functionality that i want. But i don't know how to get the > QLineEdit (or whatever is used for a cell) object from a QTableView > without subclassing it. > > Is there a simple way to get the functionality as described above > without subclassing QTableView? > > Best regards, > Mark
Right.. Answering my own question in case others find themselves stuck with the same requirement. QTableView::setItemDelegate is the solution. That takes a QAbstractItemDelegate. You should make your own delegate (on top of QItemDelegate) like so: CustomDelegate : public QItemDelegate { ... }; Then you should re-implement the createEditor method with whatever component you want. In my case i simply make a QLineEdit and set readOnly to false. That did it for me. _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest