Re: rotate text help

from
[Jeff Lacki]

Subject:

Re: rotate text help

From:

Jeff Lacki

Date:

Mon, 27 Mar 2006 12:43:18 -0800 PST

Thank you for your suggestions Justin:
> I'm not sure what you mean by "My QCanvasRectangle contains a QCanvasText",
> but it cant be good. QCanvasItems are have no parent child relationship and
> you definatly cannot
> have a QCanvasRectangle with other items as class members.
Ill explain. I have subclassed a QCanvasRectangle. Inside this
class I create a label pointer (Q3CanvasText) and other text items.
I do this so that when the canvasview collision occurs, I call the
move method in my subclass which takes care of moving all the text items
as well as the Q3CanvasRectangle subclass itself.
> You could have added a call to QPainter::drawText to your posted code and be
> almost there.
I see what you mean, however, it seems my biggest issue with
what I have is QPaintDevice as it relates to QPainter.begin()
which takes a QPaintDevice. Since Ive been stuck in the canvas-only
world so far, Im trying to learn more about the painter stuff.
My understanding is that painter (and related stuff) is essentially
what canvas things are built on top of. Thats just an aside to
my problem.
Anyhow I tried this bit of code, but dont understand QPixmap well
enough yet either. Ill replace the 120 width/height later when
I can actually get this working:
in my Q3CanvasRectangle subclass:
QString test("Testing");
RotatedText *rt = new RotatedText(test,canvas);
QPainter p;
rt->draw(p);
then draw method of RotatedText:
void
RotatedText::draw(QPainter &p)
{
QPixmap res(120,120);
p.begin(&res);
p.save();
p.rotate(90);
p.translate(-x(), -y());
p.translate(y(), -x());
p.drawText(x(),y(),_text);
// Have the base class draw it
Q3CanvasText::draw(p);
p.restore();
p.end();
}
Thanks again,
Jeff
--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/