You are not logged in.

  • "salmanmanekia" is male
  • "salmanmanekia" started this thread

Posts: 85

Location: Finland

Occupation: Software Developement

  • Send private message

1

Thursday, June 26th 2008, 12:19pm

QPainter ,QPainterPath...and cubicTo()

Hi,

I want to make the green circle move through the big grey circle as if it is a progress bar...

i am not at all sure how to accomplish this,for my part i think it would be somehow through QPainterPath,its what i think....

also i cannot understand the CubicTo() function of QpainterPath..the diagram in the document http://doc.trolltech.com/4.4/qpainterpath.html#cubicTo

makes it even more confusing for me..any help ..atleast on the first question ;)
salmanmanekia has attached the following file:
  • 1.GIF (3.52 kB - 38 times downloaded - latest: Mar 6th 2014, 8:41am)

2

Thursday, June 26th 2008, 6:35pm

if the grey circle is QGraphicsPathItem

you can use QPainterPath::pointAt( double x ) with x in [ 0 .. 1 ]
and use the result to movethe green circle

with
greenItem->setPos( greenItem->pointAt( x ) )
the green circle will turn on the grey circle
Nicolas

  • "salmanmanekia" is male
  • "salmanmanekia" started this thread

Posts: 85

Location: Finland

Occupation: Software Developement

  • Send private message

3

Monday, June 30th 2008, 1:41pm

Hi,
Thanks ..but there is no function as pointAt ...i found a function named as pointAtPercent()... http://doc.trolltech.com/4.4/qpainterpat…#pointAtPercent..
also the green circle which i want to move is the painterPath while i have drawn the grey circle as a Painter..

4

Monday, June 30th 2008, 7:00pm

excuse me,
pointAt --> pointAtPercent
it was distraction

set the grey circle parent item of the green circle
and use
greenCircle->setPos( greyCircle->path().pointAtPercent( pc ) )
to move the green circle
Nicolas

  • "salmanmanekia" is male
  • "salmanmanekia" started this thread

Posts: 85

Location: Finland

Occupation: Software Developement

  • Send private message

5

Monday, June 30th 2008, 7:43pm

correct me if i am wrong...what you mean here is that green circle and grey circle both should be Graphics Item ? also i cannot find path() function which you mentioned in
greenCircle->setPos( greyCircle->path().pointAtPercent( pc ) ) .. and can you be more clear with the last part of this statment ...
i mean ->path().pointAtPercent( pc )..
Thanks Again..

  • "salmanmanekia" is male
  • "salmanmanekia" started this thread

Posts: 85

Location: Finland

Occupation: Software Developement

  • Send private message

6

Tuesday, July 1st 2008, 8:46am

are you sure that path() function should be used...because
path does this function..'Returns the path. This may contain symbolic links, but never contains redundant ".", ".." or multiple separators.'..chk out the link
http://web.mit.edu/qt-dynamic_v4.3.3/www/qdir.html#path

7

Tuesday, July 1st 2008, 9:53am

QGraphicsPathItem::path() function
Nicolas

  • "salmanmanekia" is male
  • "salmanmanekia" started this thread

Posts: 85

Location: Finland

Occupation: Software Developement

  • Send private message

8

Tuesday, July 1st 2008, 10:07am

Thanks for your reply...can you please also clear that green circle and grey circle both should be Graphics Item ?..beacuse upuntil now i have drawn green circle with the help of QPainterPath and using fill path() as you can see below...so do i have to change the below code ...

void ProgressWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
painter->save();
painter->setPen(QPen(QBrush(Qt::gray,Qt:: solidPattern),30,Qt:: solidLine,Qt::FlatCap,Qt::MiterJoin));
painter->drawEllipse(0, 0, 200, 200);
painter->restore();
painter->fillPath( path, QBrush( Qt::green, Qt:: solidPattern ) );
}

9

Tuesday, July 1st 2008, 2:02pm

do not subclass QGraphicsItem

in place of YourItemClass, use QGraphicsPathItem
Nicolas