[Kde-bindings] Custom data types in a QAbstractItemModel?

IBBoard ibboard at gmail.com
Wed Feb 10 20:38:12 UTC 2010


Hi,

I'm back with another Qt#/Qyoto question - this time about the
Model/View code. I've tried reading the documentation, but while I can
see what looks like a promising section of the API I've not been able to
work out how to actually use it!

Basically, I'm used to WinForms (which lets you set a model of arbitrary
data objects) and GTK# (which also lets you add arbitrary models in a
data store that widgets use) in .Net/C# and I've used SWT in Java (which
doesn't have full models, but does let you call a "setData" function
with a string and an object, which gets a similar effect in most
situations).

Looking at QAbstractItemModel, it seems to take QVariants as its data.
Looking at QVariant there is a "UserType" as well as all of the
Q-wrappers around standard data types. Unfortunately I've not been able
how to use the "UserType" to wrap a user type yet. I've tried
"QVariant.FromValue(object)", but that complains about not being able to
infer generic parameters and if I try
"QVariant.FromValue<QVariant>(object)" then it throws class cast exceptions.

Can anyone explain how I can do this with Qyoto (if it is possible) or
what the alternative is? Or even just point me to some documentation
that I've missed :)

In the mean time I'll keep on searching, poking and seeing if the penny
suddenly drops.

Thanks,

IBBoard



More information about the Kde-bindings mailing list