[Qt-interest] Editable QTreeView / QAbstractItemModel

Alessandro Vanzulli alessandro.vanzulli at gmail.com
Thu Apr 30 22:20:10 CEST 2009


Hi,

the current behaviour is related to the use of Default Item Delegate for
editing an item inside the QTreeView. The same situation will occur with the
QTableView and other Q*View (now I don't remember which is the current
abstracted classes).

Your model should reimplment the data, setData (for the interested roles
like DisplayRole, EditRole and so on...) depending on the specific behaviour
requested.

For editing the standard types, the default delegate object connected to the
QTreeView should be enough, but for example, if for a specific column, or
row, you shoul select the value from a QComboBox, you have to create your
own Delegate class and then set it as delegate object for the specific row /
column inside the QTreeView.

If you have other questions, you can ask without any problem.

Bye.

Alessandro






On Thu, Apr 30, 2009 at 9:43 PM, Georg Grabler <ggrabler at gmail.com> wrote:

> Hello,
>
> I'd like to implement an editable QTreeView with a subclassed
> QAbstractItemModel as a data provider.
>
> Now, I can do so. I have a QTreeView, which actually is editable. For the
> "better" user experience, I'd like to do the following:
> If the user double clicks an item, it switches to edit mode (done so far,
> works by reimplementing setData and flags).
> I'd like the text in the column of the TreeView to be persistent on double
> click, means - the text in there isn't changed, but selected. By default,
> the Model / View deletes the text in the box.
> How can I make the view / model to keep the text until the user deletes it?
> Of course, by pressing escape, the text is still there (cancel edit).
>
> Any hints on that?
>
> Kind regards,
> Georg
>
> PS: I took the example of Model / View programming 1:1 for this, but I
> havn't found a possibility to keep the data which was in there before.
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090430/25e976f9/attachment.html 


More information about the Qt-interest-old mailing list