yaseminyilmaz
2nd April 2012, 10:07
Hi all,
I've created a custom class (named as Flow) inherited by QGraphicsItem. It's composing of an arrow and curve. I've used the function itemAt to determine which item has selected when QGraphicsScene::mousePressEvent is called. But it does not always return correct item. Otherwise I've written the folllowing function for manual detection. It's working correctly. But I want to learn why sometimes QGraphicsScene can not detect item selected by pressing mouse? Is there a more sensible method than manual point control?
int getMatchedFlow(QPointF pos)
{
int fID = -1;
QList<Flow*> mFlowList = mGroupStore.keys();
QList<Flow*>::iterator i;
Flow *pFlow;
for (i = mFlowList.begin(); i != mFlowList.end(); ++i)
{
pFlow = (Flow*)*i;
if (pFlow->checkPointSet(pos))
{
fID = pFlow->getID();
break;
}
}
return fID;
}
bool Flow::checkPointSet(QPointF point)
{
bool rc = false;
if (mBoundingPath.contains(point))
{
rc = true;
}
return rc;
}
Thanks a lot for your helps,
I've created a custom class (named as Flow) inherited by QGraphicsItem. It's composing of an arrow and curve. I've used the function itemAt to determine which item has selected when QGraphicsScene::mousePressEvent is called. But it does not always return correct item. Otherwise I've written the folllowing function for manual detection. It's working correctly. But I want to learn why sometimes QGraphicsScene can not detect item selected by pressing mouse? Is there a more sensible method than manual point control?
int getMatchedFlow(QPointF pos)
{
int fID = -1;
QList<Flow*> mFlowList = mGroupStore.keys();
QList<Flow*>::iterator i;
Flow *pFlow;
for (i = mFlowList.begin(); i != mFlowList.end(); ++i)
{
pFlow = (Flow*)*i;
if (pFlow->checkPointSet(pos))
{
fID = pFlow->getID();
break;
}
}
return fID;
}
bool Flow::checkPointSet(QPointF point)
{
bool rc = false;
if (mBoundingPath.contains(point))
{
rc = true;
}
return rc;
}
Thanks a lot for your helps,