本文整理汇总了C++中QDragEnterEvent::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ QDragEnterEvent::pos方法的具体用法?C++ QDragEnterEvent::pos怎么用?C++ QDragEnterEvent::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDragEnterEvent
的用法示例。
在下文中一共展示了QDragEnterEvent::pos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event)
{
if (m_currentMenu && m_currentMenu->isVisible()
&& !m_currentMenu->rect().contains(m_currentMenu->mapFromGlobal(QCursor::pos())))
{
// To switch root folders as in a menubar
KBookmarkActionMenu* act = dynamic_cast<KBookmarkActionMenu *>(actionAt(mapFromGlobal(QCursor::pos())));
if (event->type() == QEvent::MouseMove && act && act->menu() != m_currentMenu)
{
m_currentMenu->hide();
QPoint pos = mapToGlobal(widgetForAction(act)->pos());
act->menu()->popup(QPoint(pos.x(), pos.y() + widgetForAction(act)->height()));
}
else if (event->type() == QEvent::MouseButtonPress && act)
{
m_currentMenu->hide();
}
return QObject::eventFilter(watched, event);
}
switch (event->type())
{
case QEvent::Show:
{
if (!m_filled)
{
BookmarkManager::self()->fillBookmarkBar(this);
m_filled = true;
}
}
break;
case QEvent::ActionRemoved:
{
QActionEvent *actionEvent = static_cast<QActionEvent*>(event);
if (actionEvent && actionEvent->action() != m_dropAction)
{
QWidget *widget = widgetForAction(actionEvent->action());
if (widget)
{
widget->removeEventFilter(this);
}
}
}
break;
case QEvent::ParentChange:
{
QActionEvent *actionEvent = static_cast<QActionEvent*>(event);
if (actionEvent && actionEvent->action() != m_dropAction)
{
QWidget *widget = widgetForAction(actionEvent->action());
if (widget)
{
widget->removeEventFilter(this);
}
}
}
break;
case QEvent::DragEnter:
{
QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent*>(event);
if (dragEvent->mimeData()->hasFormat(BookmarkManager::bookmark_mime_type())
|| dragEvent->mimeData()->hasFormat("text/uri-list")
|| dragEvent->mimeData()->hasFormat("text/plain"))
{
QFrame* dropIndicatorWidget = new QFrame(this);
dropIndicatorWidget->setFrameShape(QFrame::VLine);
m_dropAction = insertWidget(actionAt(dragEvent->pos()), dropIndicatorWidget);
dragEvent->accept();
}
}
break;
case QEvent::DragLeave:
{
QDragLeaveEvent *dragEvent = static_cast<QDragLeaveEvent*>(event);
if (m_checkedAction)
{
m_checkedAction->setCheckable(false);
m_checkedAction->setChecked(false);
}
delete m_dropAction;
m_dropAction = 0;
dragEvent->accept();
}
break;
case QEvent::DragMove:
{
QDragMoveEvent *dragEvent = static_cast<QDragMoveEvent*>(event);
if (dragEvent->mimeData()->hasFormat(BookmarkManager::bookmark_mime_type())
|| dragEvent->mimeData()->hasFormat("text/uri-list")
//.........这里部分代码省略.........