ensky_cy
7th December 2009, 07:36
int i = 1;
QPoint posi = QCursor::pos();
QPointF postemp = (QPointF)posi;
foreach(coordinator cor1, m_pageListback1)
{
if((cor1.x <= postemp.x()) && (cor1.y <= postemp.y()) && ((cor1.x+192) >= postemp.x()) && ((cor1.y+256) >= postemp.y()))
{
pagenum = i; //index of the item in the QVector
break;
}
i++;
}
m_pageListback1 is a QVector Container ,they are items' top-left coordinate(these coordinates are the result of QGraphicsItem::mapToScene ).every item's width = 192,height = 256.I want to judge ,whether the cursor is in the scope of the item.
but it is not accurate.Is there some way to unify the coordinate.
Thanks!!!!!
QPoint posi = QCursor::pos();
QPointF postemp = (QPointF)posi;
foreach(coordinator cor1, m_pageListback1)
{
if((cor1.x <= postemp.x()) && (cor1.y <= postemp.y()) && ((cor1.x+192) >= postemp.x()) && ((cor1.y+256) >= postemp.y()))
{
pagenum = i; //index of the item in the QVector
break;
}
i++;
}
m_pageListback1 is a QVector Container ,they are items' top-left coordinate(these coordinates are the result of QGraphicsItem::mapToScene ).every item's width = 192,height = 256.I want to judge ,whether the cursor is in the scope of the item.
but it is not accurate.Is there some way to unify the coordinate.
Thanks!!!!!