本文整理汇总了C++中MainMenu::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ MainMenu::getPosition方法的具体用法?C++ MainMenu::getPosition怎么用?C++ MainMenu::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainMenu
的用法示例。
在下文中一共展示了MainMenu::getPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mousePressEvent
void ItemScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if(this->sceneType == MenuDisplay)
{
cout << "Width: " << this->sceneRect().width() << endl;
QList<QGraphicsView*> parentViews = this->views();
cout << parentViews.size() << endl;
MainMenu* view = (MainMenu*)parentViews.at(0);
int viewPosX, viewPosY, viewWidth, viewHeight, imagePosX, imagePosY, imageWidth, imageHeight;
viewPosX = view->getPosition()->x();
viewPosY = view->getPosition()->y();
viewWidth = view->width();
viewHeight = view->height();
imagePosX = this->imageDisplay->imageFileItem->pos().x();
imagePosY = this->imageDisplay->imageFileItem->pos().y();
imageWidth = this->imageDisplay->imageFileItem->boundingRect().width();
imageHeight = this->imageDisplay->imageFileItem->boundingRect().height();
if( (viewPosX + viewWidth >= imagePosX || viewPosX + viewWidth >= imagePosX + imageWidth ) &&
(viewPosY <= imagePosY || viewPosY <= imagePosY + imageHeight) )
{
QPointF position(viewPosX + event->scenePos().x(), viewPosY + event->scenePos().y());
this->imageDisplay->addSelectionMarker(position);
}
}
update();
QGraphicsScene::mousePressEvent(event);
}