| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 2 | |
Hello, I'm trying to create a composed shape with my painter : QRect rectangleLeftUserName(option.rect.x() + 10, option.rect.y(), 20, 20); QRect rectangleUserName(option.rect.x() + 20, option.rect.y(), 100, 20); QRect rectangleRightUserName(option.rect.x() + 110, option.rect.y(), 20, 20); painter->drawEllipse(rectangleLeftUserName); painter->drawRect(rectangleUserName); painter->drawEllipse(rectangleRightUserName); It's creating three different standalone shapes, is there a way to merge thoses 3 shapes in one graphical element ? Thanks. Ben.
Attachment:
howTo.jpg
Description: JPEG image
Not sure I understand what you mean. There is no painter->drawEllipseRectEllipse(...) in qt. But maybe QPicture might do what you need. Guido > It's creating three different standalone shapes, > > is there a way to merge thoses 3 shapes in one graphical element ? -- [ signature omitted ]
I've come up with that code to display my own custom shape using
QPainterPath :
the "true" rounded edge rectangle.
It's working like a charm, thanks again guys.
My only concern is newing a QPainterPath everytime I want to display one,
any thoughts to improve it ?
//=============================================================================
//=============================================================================
const QPainterPath * ZeContactDelegate::ZeRoundPath(QRectF & rectangle,
QPointF & position) const
{
QPainterPath * myPath = new QPainterPath;
myPath->moveTo(position.x() + (rectangle.height() / 2), position.y());
myPath->lineTo(position.x() + rectangle.width(), position.y());
myPath->arcTo(position.x() + rectangle.width(), position.y(),
rectangle.height(), rectangle.height(), 90, -180);
myPath->lineTo(position.x() + rectangle.height(), position.y() +
rectangle.height());
myPath->arcTo(position.x(), position.y() + rectangle.height(),
rectangle.height(), -rectangle.height(), 90, 180);
return myPath;
}
----- Original Message -----
From: "Guido Seifert" <wargand@xxxxxx>
To: <qt-interest@xxxxxxxxxxxxx>
Sent: Wednesday, February 07, 2007 4:04 PM
Subject: Re: Painter Issue.
> Not sure I understand what you mean. There is no
> painter->drawEllipseRectEllipse(...)
> in qt. But maybe QPicture might do what you need.
>
> Guido
>
>> It's creating three different standalone shapes,
>>
>> is there a way to merge thoses 3 shapes in one graphical element ?
>
> --
> 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/
>
>
--
[ signature omitted ]
> > My only concern is newing a QPainterPath everytime I want to display one, > > any thoughts to improve it ? Do you use it very often in a loop? Does the small time to 'new' a QPainterPath object really influences your program? If not, I'd leave it as it is. Except perhaps I probably would use an auto_ptr as return value. Never used the QPainterPath class, but I don't see some sort of 'clear' method in the docu. So I suppose creating and destroying is your only option. If you really hate this, check whether your parameters changed during two calls of your method. Guido -- [ signature omitted ]