[Kde-bindings] Re: Re: qtruby: Qt::TextView issue?

Richard Dale Richard_Dale at tipitina.demon.co.uk
Fri Sep 24 00:03:39 UTC 2004


On Friday 24 September 2004 00:49, Richard Dale wrote:
> On Thursday 23 September 2004 17:08, Navindra Umanee wrote:
> > Arash Abedinzadeh <thunfisch at thunfisch.org> wrote:
> > > class MyImage < Qt::Widget
> > >         def initialize
> > >                 super()
> > >                 @image = Qt::Image.new("/path/to/image.png")
> > >         end
> > > end
> >
> > Here you're just creating a class that contains an image in a field.
> > It isn't doing anything.  If you ask it to show, there's nothing to
> > show.
> >
> > I think you should use Qt::Label to display pictures or text.
> >
> > http://doc.trolltech.com/3.3/qlabel.html#setPixmap
> >
> > Try this:
> >
> > ---------------
> > require 'Qt'
> >
> > a = Qt::Application.new(ARGV)
> >
> > image = Qt::Image.new("/home/navindra/out.png")
> > pixmap = Qt::Pixmap.new(image)
> >
> > label = Qt::Label.new(nil)
> > label.setPixmap(pixmap)
> > label.show
> >
> > a.setMainWidget(label)
> > a.exec
> > ---------------
> >
> > I just got this by playing around, maybe someone will know a better
> > way or approach or correct my syntax.
>
> That looks good to me. Note that you can use this syntax instead of
> setXXX() if you prefer:
>
> require 'Qt'
> include Qt
>
>  a = Application.new(ARGV)
>
> image = Image.new("/home/navindra/out.png")
> pixmap = Pixmap.new(image)
>
> label = Label.new(nil)
> label.pixmap = pixmap
> label.show
>
> a.mainWidget = label
> a.exec
PS: you don't need to create a Qt::Image and then a Qt::Pixmap, this works 
fine:

require 'Qt'
include Qt

a = Application.new(ARGV)

pixmap = Pixmap.new("/home/navindra/out.png")

label = Label.new(nil)
label.pixmap = pixmap
label.show

a.mainWidget = label
a.exec



More information about the Kde-bindings mailing list