The reason for the slot declaration of rowCount() is very simple :-) I use it in the view.qml (see the line: "helloText.rotation = con.get_model().rowCount()")! Calling rowCount() without the slot declaration from qml would fail. And no, it is not generally helpful, I would even say, that the opposite (declare only as many slots as really necessary) is the better solution because you get cleaner code and a narrower (=simpler) interface to the qml part.
Aaron

Am 13.01.2013 14:40, schrieb Yosef Meller:

On Sunday 13 January 2013 14:32:10 Aaron Richiger wrote:

> I think, this question is related to an earlier one from me... Anatoly

> then told me the truth about lifetimes of QObjects that are created in

> methods without any parent reference. They won't survive such a method

> call as you try to do. By giving your model a parent reference that

> survives the method call, the model will be available as well after the

> return statement. The following code also shows, that the "QVariant"

> trick is not necessary, but setting the result type to QObject is

> enough. I hope this helps...

You're right, QVariant isn't necessary, only parenting. It's not very significant though as it only appears in the slot declaration.

BTW, I see in your code that the model's rowCount method is declared as a slot. What is the value in that? Does anything use this? I'm sure it's optional because it works without it, but is it generally helpful to declare it a slot anyway?

Yosef.



_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside

_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside

Reply via email to