[Qt-interest] Fwd: Re: adding another item in QGraphicsItem

Sean Harmer sean.harmer at maps-technology.com
Sat Apr 25 16:54:23 CEST 2009


Hi,

On Saturday 25 April 2009 12:14:47 you wrote:
> ProgressItem::ProgressItem(const QRectF &rect)
>
>             : QGraphicsRectItem(rect)
>
> {
>         textItem = new QGraphicsTextItem(this);
>
>         textItem->setPos(10, 4);
>         textItem->setPlainText("In Progress");
>
> }
>
>
> void ProgressItem::paint(QPainter *painter, const  QStyleOptionGraphicsItem
> *o, QWidget *widget)
> {
>         QBrush brush(QColor(Qt::yellow));
>         painter->setBrush(QBrush(QColor(21, 155, 210, 255)));
>         painter->drawRect(rect());
>
> }
>
> i tried this one and its working .... the only problem is the text color
Good. But, why not simply call the QGraphicsRectItem::paint() function? May as 
well since you are inheriting from it.

Sean




More information about the Qt-interest-old mailing list