[Kde-bindings] TreeWidgetItem problems
Miquel
ktalanet at yahoo.es
Thu May 17 10:37:02 UTC 2007
En/na Richard Dale ha escrit:
> On Thursday 17 May 2007, Miquel wrote:
>
>> Hi there
>>
>> I'm trying to code a Tree using ruby qt bindings (Qt v4.2.0 using
>> aboutQt() info).
>>
>> This is my code.
>>
>> @tree = Qt::TreeWidget.new(self)
>> self.setCentralWidget(@tree)
>>
>> @rootItem = Qt::TreeWidgetItem.new(@tree)
>> @rootItem.setText(0, "Root")
>>
>> 0.upto(10) do |index|
>> item = Qt::TreeWidgetItem.new(@rootItem)
>> item.setText(0, "Node#{index}")
>> end
>>
>> The problem is in 'item = Qt::TreeWidgetItem.new(@rootItem)', system
>> tells me:
>>
>> unresolved constructor call Qt::TreeWidgetItem (ArgumentError)
>>
>> and reading Qt documentation there are two constructors allowed:
>>
>> QTreeWidgetItem ( QTreeWidget * parent, int type = Type )
>> QTreeWidgetItem ( QTreeWidgetItem * parent, int type = Type )
>>
>> The first one is used in the @rootNode object creation and the second
>> one is the one which produces this message.
>>
>> Can anybody help me?
>>
> I've tried it with QtRuby in the kde svn and Qt 4.3 from the current qt-copy,
> and it seems to work fine:
>
> mardigras rdale 563% irb -rQt
> irb(main):001:0> app = Qt::Application.new(ARGV)
> => #<Qt::Application:0xb7c71930 objectName="irb">
> irb(main):002:0> @tree = Qt::TreeWidget.new
> => #<Qt::TreeWidget:0xb7a948d8 objectName="", x=0, y=0, width=640, height=480>
> irb(main):003:0> @rootItem = Qt::TreeWidgetItem.new(@tree)
> => #<Qt::TreeWidgetItem:0xb7a65128>
> irb(main):004:0> item = Qt::TreeWidgetItem.new(@rootItem)
> => #<Qt::TreeWidgetItem:0xb7a469f8 parent=#<Qt::TreeWidgetItem:0xb7a65128>>
>
> What do you get if you do 'rbqtapi Qt::TreeWidgetItem' - is the constructor
> there in your version of the smoke library? Is @rootItem nil for some reason?
>
> -- Richard
> _______________________________________________
> Kde-bindings mailing list
> Kde-bindings at kde.org
> https://mail.kde.org/mailman/listinfo/kde-bindings
>
>
Hi richard
I have resolved the problem adding Qt::TreeWidgetItem::Type to the
constructor like this:
item = Qt::TreeWidgetItem.new(@rootItem, Qt::TreeWidgetItem::Type)
but if you read the Qt class docs, Type is an optional parameter :-(
The rbqtapi output is :
QTreeWidgetItem* QTreeWidgetItem::QTreeWidgetItem() QTreeWidgetItem*
QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem*) QTreeWidgetItem*
QTreeWidgetItem::QTreeWidgetItem(QTreeWidget*) QTreeWidgetItem*
QTreeWidgetItem::QTreeWidgetItem(const QTreeWidgetItem&)
QTreeWidgetItem* QTreeWidgetItem::QTreeWidgetItem(QTreeWidget*,
QTreeWidgetItem*) QTreeWidgetItem*
QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem*, QTreeWidgetItem*)
QTreeWidgetItem* QTreeWidgetItem::QTreeWidgetItem(QTreeWidget*,
QTreeWidgetItem*, int) QTreeWidgetItem*
QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem*, QTreeWidgetItem*,
int) QTreeWidgetItem*
QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem*, int)
QTreeWidgetItem* QTreeWidgetItem::QTreeWidgetItem(QTreeWidget*, int)
QTreeWidgetItem* QTreeWidgetItem::QTreeWidgetItem(QTreeWidget*, const
QStringList&) QTreeWidgetItem*
QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem*, const QStringList&)
QTreeWidgetItem* QTreeWidgetItem::QTreeWidgetItem(QTreeWidget*, const
QStringList&, int) QTreeWidgetItem*
QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem*, const QStringList&,
int) QTreeWidgetItem* QTreeWidgetItem::QTreeWidgetItem(int)
QTreeWidgetItem* QTreeWidgetItem::QTreeWidgetItem(const QStringList&)
QTreeWidgetItem* QTreeWidgetItem::QTreeWidgetItem(const QStringList&,
int)
I'm lost, because
QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem*) QTreeWidgetItem*
should satisfy my needs, shouldn't it?
Thanks for your help
Bye
Miquel
More information about the Kde-bindings
mailing list