[Kde-bindings] TreeWidgetItem problems

Richard Dale rdale at foton.es
Thu May 17 10:03:11 UTC 2007


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



More information about the Kde-bindings mailing list