PDA

View Full Version : Interview reload problem



tiptop
16th March 2008, 17:33
Hello!

I am using Interview with a QTreeView view and my own model. Some lines of the data the model works on change frequently without any user input.
I told the data-object to emit a signal which is conneted to a function in the model. This function checks which lines have changed and emits the dataChanged signal.

The signal is emitted without any problems but the view seems not to recognize this. I have to minimize and maximize the window so that the changes apply (I think this causes a reload of every line, doesn't it?).

Adding new lines works fine. When I add a new line, the refresh described above also happens. (All the other lines are refreshed when i add one single new line)

Thank you!

wysota
16th March 2008, 18:57
How do you change the data? do you use QAbstractItemModel::setData() for that? Either way, could we see the code?

tiptop
17th March 2008, 15:36
I just change the sourceData without emitting setData() function.
If I understood the manual correctly, the only thing you have to do when data is changed is emitting dataChanged() for the area of the change. ( http://doc.trolltech.com/4.3/qabstractitemmodel.html#setData ) "Note that the dataChanged() signal must be emitted explicitly when reimplementing this function."

wysota
17th March 2008, 15:54
If I understood the manual correctly, the only thing you have to do when data is changed is emitting dataChanged() for the area of the change.

Yes, that's correct. But if the data is changed by an outside source, you can do that through setData(). Either way could you show us the method you use for modifying the model?

tiptop
17th March 2008, 17:20
Well, there's nothing to show. I just use the assignment operator change the data. As I implemented my own Model, i cannot use the setData() of a base class because its implementation does nothing but returning false.
It does afaik absolutely not change anything to use a setData function which does exactly the same as two other lines in my own function.
I double checked whether the data is really set and whether the signal is really emitted - it is.
The problem seems to be in the view.

wysota
17th March 2008, 17:49
I just use the assignment operator change the data.
Hmm... what about the signal emition? Can we see the code?


As I implemented my own Model, i cannot use the setData() of a base class because its implementation does nothing but returning false.
I didn't say anything about the base class. I meant you should implement setData() for your model and use it to operate on it.


The problem seems to be in the view.

Unless you have subclassed the view and broken something there it should work. Otherwise the problem is within your model.