January 17, 2012

jech jech
Ant Farmer
128 posts

TextEdit in a ListView delegate

 

Hi,

I’m trying to implement a list of text items. The text is editable, the delegate component contains a TextEdit item.

The behavior should be following:
1) As soon as the text changes from the initial value a save buttonto store the cahnges appears (this is already implemented).
2) When I click on another item, the change will not be saved and the TextEdit.text will return to the initial value.

I don’t know how should I implement the second part. Do you have any idea?

2 replies

January 17, 2012

Volker Volker
Ant Farmer
5428 posts

Did you implement method setModelData() of the delegate? This is called in case the view ends the edit process in order to transfer the edit widgets contents to the model.

(oops … it’s about Qt Quick, dunno, if that applies here too.)

January 17, 2012

jech jech
Ant Farmer
128 posts

I solved the problem easily with a completely different approach then what I was trying first. I use Python (PySide) for the application logic and I didn’t realize that I only need to call changed signal of a list item and the data will revert to the original values.

Sometimes it is better to take a day off and then look at the problem from a different side.

 
  ‹‹ code examples - statemachine using Qt Quick and C++      How can I get the current QML path in QML ››

You must log in to post a reply. Not a member yet? Register here!