[Qt-interest] Editable QTreeView / QAbstractItemModel

Georg Grabler ggrabler at gmail.com
Fri May 8 00:43:09 CEST 2009


Hello,

Indeed, I've still questions / problems regarding this one. I'm sorry, but
I'm really just getting started with this :-(.

I've commited a project to my private SVN (public readable, with webdav),
basically a test project. It's called jukTest (not for no reason, actually
I'm playing with the JuK source removing k3 dependencies learning some Qt, a
test project since it's easier to play around with before touching the real
code).

Now, it seems as if I won't need a delegate for editing, but it seems as if
something is wrong in the code of my model, means when editing, the model
doesn't know about the values in the view (also not if i add the delegate
and read the data at the given index manually).

I'd appreciate if anyone could take a look why the data is actually cleared
when editing the item in the treeview, and could give me hints about what
mistake I did.

http://svn.stiat.net/repos/jukTest/

Thanks,
Georg

On Thu, Apr 30, 2009 at 1:20 PM, Alessandro Vanzulli <
alessandro.vanzulli at gmail.com> wrote:

> 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/20090507/1df43b9c/attachment.html 


More information about the Qt-interest-old mailing list