Qt-interest Archive, December 2006
selecting QGraphicsPathItem
Message 1 in thread
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#3333ff">
Hi,<br>
I am using QGraphicsPath Item to do some plot, which is not a closed
curve. <br>
I want to select the path, when user clicks on it. <br>
what shape() and contains() function returns a closed shape constructed
from the path. Thus even clicking some interior region selects it. What
it checks is intersection of an area with a point.<br>
On the other hand what I want is intersection of a curve (the path)
with an area (a small rect around the mouse).<br>
Anyone has idea how to select a path (curve) based on the curve
intersection , and not based on the area under the curve ? <br>
<br>
Thanks<br>
abir
</body>
</html>
--
[ signature omitted ]
Message 2 in thread
Abir Basak wrote:
> Hi,
> I am using QGraphicsPath Item to do some plot, which is not a closed
> curve.
> I want to select the path, when user clicks on it.
> what shape() and contains() function returns a closed shape
> constructed from the path. Thus even clicking some interior region
> selects it. What it checks is intersection of an area with a point.
> On the other hand what I want is intersection of a curve (the path)
> with an area (a small rect around the mouse).
> Anyone has idea how to select a path (curve) based on the curve
> intersection , and not based on the area under the curve ?
You'll need to subclass QGraphicsPath and reimplement the path()
function. The way I did this is to create a separate QPainterPath that
represents the shape of the QGraphicsPath, with a little margin to make
it clickable. This QPainterPath should trace the perimeter of your
actual shape, forward and returning to completely enclose the
QGraphicsPath. Then return that QPainterPath in your shape() function.
That's kind of hard to describe in words. I wish I had a picture...
--Dave
--
[ signature omitted ]
Message 3 in thread
Dave Smith wrote:
> You'll need to subclass QGraphicsPath and reimplement the path()
> function. The way I did this is to create a separate QPainterPath that
> represents the shape of the QGraphicsPath, with a little margin to
> make it clickable. This QPainterPath should trace the perimeter of
> your actual shape, forward and returning to completely enclose the
> QGraphicsPath. Then return that QPainterPath in your shape() function.
Woops, I meant shape() function. You can erase "path()" from the text
above! :-/
--Dave
--
[ signature omitted ]
Message 4 in thread
On Wednesday 06 December 2006 16:55, Dave Smith wrote:
> Abir Basak wrote:
> > Hi,
> > I am using QGraphicsPath Item to do some plot, which is not a closed
> > curve.
> > I want to select the path, when user clicks on it.
> > what shape() and contains() function returns a closed shape
> > constructed from the path. Thus even clicking some interior region
> > selects it. What it checks is intersection of an area with a point.
> > On the other hand what I want is intersection of a curve (the path)
> > with an area (a small rect around the mouse).
> > Anyone has idea how to select a path (curve) based on the curve
> > intersection , and not based on the area under the curve ?
>
> You'll need to subclass QGraphicsPath and reimplement the path()
> function. The way I did this is to create a separate QPainterPath that
> represents the shape of the QGraphicsPath, with a little margin to make
> it clickable. This QPainterPath should trace the perimeter of your
> actual shape, forward and returning to completely enclose the
> QGraphicsPath. Then return that QPainterPath in your shape() function.
You might use a QPainterPathStroker. Saves brain cycles (and code) ;)
--Robert
> That's kind of hard to describe in words. I wish I had a picture...
>
> --Dave
>
> --
> 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 ]
Message 5 in thread
Robert Gstöhl wrote:
>> You'll need to subclass QGraphicsPath and reimplement the shape()
>> function. The way I did this is to create a separate QPainterPath that
>> represents the shape of the QGraphicsPath, with a little margin to make
>> it clickable. This QPainterPath should trace the perimeter of your
>> actual shape, forward and returning to completely enclose the
>> QGraphicsPath. Then return that QPainterPath in your shape() function.
>>
>
> You might use a QPainterPathStroker. Saves brain cycles (and code) ;)
>
Brilliant! I had not seen that class yet. I just removed about 50 lines
of code from my current project in favor of one simple
QPainterPathStroker! Thank you Robert!
--Dave
--
[ signature omitted ]