[Kde-bindings] TreeWidgetItem problems

Richard Dale rdale at foton.es
Thu May 17 16:10:31 UTC 2007


On Thursday 17 May 2007, Miquel Oliete wrote:
> 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
>
> It's the Kubuntu's precompiled version.
>
> rbqtapi -v --> qtruby using Qt-4.1.4
>
> so I see that the Qt version used by qtruby is not the same shown in the
> aboutQt() method, is it possible? Is there an error?
I'm not sure, but that isn't a problem with QtRuby itself - it should work 
fine with both Qt 4.1.4 and Qt 4.2.

> I Qt version used by qtruby is 4.1.4 I understand why a lot of methods
> were not found before.
I found out what the problem is from the QtRuby ChangeLog, and so I have 
already fixed this one:

2006-12-16  Richard Dale  <rdale at foton.es>

	* There is no way to distinguish between the two constructors:
	 	 QTreeWidgetItem (const QTreeWidgetItem & other) 
		 QTreeWidgetItem (QTreeWidgetItem * parent, const QStringList & 
           strings, int type = Type)
	  when the latter has a single argument. So force the second variant to 
      be called

-- Richard



More information about the Kde-bindings mailing list