[Qtscript-bindings] [QtScript] QListView and items not rendered with custom QItemDelegate
Kent Hansen
khansen at trolltech.com
Mon Jan 19 13:13:00 CET 2009
Hi,
M. Uenalan wrote:
> Hi,
>
> I want to construct a QListView with QTextBrowser items. Therefore I
> went forward to derive a custom QItemDelegate. But in this code the
> listview is not rendered at all ? The paint function of my derived
> class is not called as well. Any hints ?
>
[...]
> function QItemDelegateRichtext()
> {
> this.constructor(); // call constructor of SUPER
> this.textprop = "test";
> }
>
"this.constructor()" should rather be "QItemDelegate.call(this)"
[...]
> var pen = new QPen(Qt.red);
> var brush = new QPen(Qt.yellow);
>
The bindings currently doesn't provide the implicit conversion that C++
does, so you will have to do "new QPen(new QColor(Qt.red))". And the
brush expression should probably be "new QBrush(...)". See
http://code.google.com/p/qtscriptgenerator/issues/detail?id=26
> painter.drawRect(option.rect);
>
QStyleOption objects currently can't be manipulated via the bindings
currently; see
http://code.google.com/p/qtscriptgenerator/issues/detail?id=25
[...]
> var mi = new QModelIndex();
> mi.column = 0;
> mi.row = 0;
>
You can't construct a QModelIndex like that. You have to call the
model's index() function to obtain a valid QModelIndex.
> t.model = model;
> t.itemdelegate = del;
>
The model and delegate aren't properties of the view. You'll have to set
them using setModel() and setItemDelegate().
I recommend taking a look at the Qt class documentation to get an
overview of which things are QObject properties (and hence directly
reflected through the bindings) and which aren't. You can also take a
look at the documentation that's generated for the bindings (created
under path-to-qtscriptgenerator/doc).
(What happens in the above case is that the QtScript object will indeed
have properties "model" and "itemdelegate" after the assignments, but
these don't have any effect on the underlying C++ object, since they
aren't QObject properties.)
Thanks for reporting.
Regards,
Kent
More information about the Qtscript-bindings
mailing list