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

Richard Dale Richard_Dale at tipitina.demon.co.uk
Fri Apr 15 08:55:42 UTC 2005


On Friday 15 April 2005 00:46, jm wrote:
> On 14/04/2005, at 10:07 PM, jm wrote:
> > 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.
>
> Alright it was a stupid question. The setFont method belongs to the
> Painter class not the String class. Which means store old value, set
> new, drawText(), reset old value. Alot of effort for one string. Time
> to add a method to do it in one step. BTW, p.font = blah works nicely
> implace of p.setFont(blah).

Maybe use a Qt::Label, rather than draw the text with a Qt::Painter?

require 'Qt'

a = Qt::Application.new(ARGV)
hello = Qt::Label.new(Time.now.strftime('%H:%M'), nil)
hello.resize(100, 30)
hello.font = Qt::Font.new("Times", 18, Qt::Font::Bold)
a.setMainWidget(hello)
hello.show()
a.exec()

-- Richard



More information about the Kde-bindings mailing list