本文整理汇总了C++中QContextMenuEvent::x方法的典型用法代码示例。如果您正苦于以下问题:C++ QContextMenuEvent::x方法的具体用法?C++ QContextMenuEvent::x怎么用?C++ QContextMenuEvent::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContextMenuEvent
的用法示例。
在下文中一共展示了QContextMenuEvent::x方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
VisualNode*
TreeCanvas::eventNode(QEvent* event) {
int x = 0;
int y = 0;
switch (event->type()) {
case QEvent::ToolTip:
{
QHelpEvent* he = static_cast<QHelpEvent*>(event);
x = he->x();
y = he->y();
break;
}
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
{
QMouseEvent* me = static_cast<QMouseEvent*>(event);
x = me->x();
y = me->y();
break;
}
case QEvent::ContextMenu:
{
QContextMenuEvent* ce = static_cast<QContextMenuEvent*>(event);
x = ce->x();
y = ce->y();
break;
}
default:
return NULL;
}
QAbstractScrollArea* sa =
static_cast<QAbstractScrollArea*>(parentWidget()->parentWidget());
int xoff = sa->horizontalScrollBar()->value()/scale;
int yoff = sa->verticalScrollBar()->value()/scale;
BoundingBox bb = root->getBoundingBox();
int w =
static_cast<int>((bb.right-bb.left+Layout::extent)*scale);
if (w < sa->viewport()->width())
xoff -= (sa->viewport()->width()-w)/2;
VisualNode* n;
n = root->findNode(*na,
static_cast<int>(x/scale-xtrans+xoff),
static_cast<int>((y-30)/scale+yoff));
return n;
}