Custom paint events make me smile
When creating our own QtRuby GUI widget, we can override the paintEvent method to make it look however we like:
require 'Qt'
class Smiley < Qt::Widget
def paintEvent(e)
p = Qt::Painter.new(self)
p.setPen(Qt::blue)
# Face
p.drawEllipse(0,0, width-2, height-2)
# Eyes
p.drawEllipse(width / 3, height / 4,10,10)
p.drawEllipse(width / 3 * 2, height / 4,10,10)
# Nose
p.drawEllipse(width / 2, height / 5 * 2, 10, 10)
# Mouth
p.drawArc(width/4, height / 3 * 2, width / 2, 50, -2880, 2880)
p.dispose
end
end
app = Qt::Application.new(ARGV)
s = Smiley.new(nil)
app.setMainWidget(s)
s.show
app.exec
gives us:

October 4th, 2005 at 11:13 pm
you got a test for that (-:
October 21st, 2005 at 11:58 am
Could you give us some more examples like line thickness and filling ellipse’s with a solid color?
November 6th, 2005 at 1:45 am
check http://doc.trolltech.com/ you’ll find it very easy to fill it with a solid color or do whatever you like….