[Kde-bindings] qtruby: Qt::String uninit const

jm jeffm at ghostgun.com
Thu Apr 14 12:07:52 UTC 2005


On 14/04/2005, at 6:37 PM, Richard Dale wrote:
> Yes, you don't need to use Qt::String at all in QtRuby. Everywhere you 
> see a
> QString parament in the C++ api you can use a ruby string and it will 
> be
> automatically converted. Also the value of $KCODE is used to correctly
> convert to and from a unicode QString, according to the current ruby 
> string
> format.
>
> This should work fine:
>
>  class Thing < Qt::Widget
>     ....
>  def  paintEvent(e)
>       #s = Qt::String.new('aweeee') #Time.now.strftime('%H:%M'))
>       p = Qt::Painter.new(self)
>       0.upto(5) do |n|
>         p.drawText(50,50*n, ".")
>       end
>       s =   Time.now.strftime('%H:%M')  #<--- line 45
>       p.drawText(250, 20, 50, 25, Qt::AlignRight, s)
>       p.drawLine(20, 50, 280, 50)
>       p.end
>     end
>  ....
>  end
>

I should have been more specific. I made the mistake of telling you how 
I'm trying to do something instead of what I'm trying to do. What I'm 
trying to do it to print the time as give by

  Time.now.strftime('%H:%M')

and print/draw it in a large font within the widget without affecting 
anything else that is drawn.

J.




More information about the Kde-bindings mailing list