本文整理汇总了C++中QContextMenuEvent::globalPos方法的典型用法代码示例。如果您正苦于以下问题:C++ QContextMenuEvent::globalPos方法的具体用法?C++ QContextMenuEvent::globalPos怎么用?C++ QContextMenuEvent::globalPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContextMenuEvent
的用法示例。
在下文中一共展示了QContextMenuEvent::globalPos方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool StayPoppedUpComboBox::eventFilter(QObject* o, QEvent* e)
{
// The combo box has installed an event filter on the view.
// If it catches a valid mouse button release there, it will hide the popup.
// Here we prevent this by eating the event ourselves,
// and then dispatching it to its destination.
if (o == m_view || o == m_view->viewport())
{
switch (e->type())
{
case QEvent::MouseButtonRelease:
{
QMouseEvent* m = static_cast<QMouseEvent*>(e);
if (m_view->isVisible() && m_view->rect().contains(m->pos()))
{
if (o == m_view)
{
o->event(e);
}
else
// Viewport: Calling event() does not work, viewportEvent() is needed.
// This is the event that gets redirected to the QTreeView finally!
{
sendViewportEventToView(e);
}
// we have dispatched the event privately; we filter it out from the main dispatching
return true;
}
break;
}
case QEvent::ContextMenu:
{
if (o != m_view)
{
// for whatever reason, the position of the event is slightly wrong
QContextMenuEvent* m = static_cast<QContextMenuEvent*>(e);
QPoint correctPos = m_view->viewport()->mapFromGlobal(m->globalPos());
QContextMenuEvent corrected(m->reason(), correctPos, m->globalPos(), m->modifiers());
sendViewportEventToView(&corrected);
return true;
}
break;
}
default:
break;
}
}
return QComboBox::eventFilter(o, e);
}
示例2: eventFilter
bool AlbumCoverManager::eventFilter(QObject* obj, QEvent* event) {
if (obj == ui_->albums && event->type() == QEvent::ContextMenu) {
context_menu_items_ = ui_->albums->selectedItems();
if (context_menu_items_.isEmpty()) return false;
bool some_with_covers = false;
for (QListWidgetItem* item : context_menu_items_) {
if (item->icon().cacheKey() != no_cover_icon_.cacheKey())
some_with_covers = true;
}
album_cover_choice_controller_->cover_from_file_action()->setEnabled(
context_menu_items_.size() == 1);
album_cover_choice_controller_->cover_from_url_action()->setEnabled(
context_menu_items_.size() == 1);
album_cover_choice_controller_->show_cover_action()->setEnabled(
some_with_covers && context_menu_items_.size() == 1);
album_cover_choice_controller_->unset_cover_action()->setEnabled(
some_with_covers);
album_cover_choice_controller_->search_for_cover_action()->setEnabled(
app_->cover_providers()->HasAnyProviders());
QContextMenuEvent* e = static_cast<QContextMenuEvent*>(event);
context_menu_->popup(e->globalPos());
return true;
}
return QMainWindow::eventFilter(obj, event);
}
示例3: IntPoint
WebKitPlatformMouseEvent::WebKitPlatformMouseEvent(QInputEvent* event, int clickCount)
{
m_timestamp = WTF::currentTime();
bool isContextMenuEvent = false;
#ifndef QT_NO_CONTEXTMENU
if (event->type() == QEvent::ContextMenu) {
isContextMenuEvent = true;
m_type = PlatformEvent::MousePressed;
QContextMenuEvent* ce = static_cast<QContextMenuEvent*>(event);
m_position = IntPoint(ce->pos());
m_globalPosition = IntPoint(ce->globalPos());
m_button = RightButton;
}
#endif
if (!isContextMenuEvent) {
PlatformEvent::Type type;
mouseEventTypeAndMouseButtonFromQEvent(event, type, m_button);
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
m_type = type;
m_position = IntPoint(mouseEvent->pos());
m_globalPosition = IntPoint(mouseEvent->globalPos());
}
m_clickCount = clickCount;
mouseEventModifiersFromQtKeyboardModifiers(event->modifiers(), m_modifiers);
}
示例4: eventFilter
bool QtKeySequenceEdit::eventFilter(QObject *o, QEvent *e)
{
if (o == m_lineEdit && e->type() == QEvent::ContextMenu) {
QContextMenuEvent *c = static_cast<QContextMenuEvent *>(e);
QMenu *menu = m_lineEdit->createStandardContextMenu();
const QList<QAction *> actions = menu->actions();
QListIterator<QAction *> itAction(actions);
while (itAction.hasNext()) {
QAction *action = itAction.next();
action->setShortcut(QKeySequence());
QString actionString = action->text();
const int pos = actionString.lastIndexOf(QLatin1Char('\t'));
if (pos > 0)
actionString.remove(pos, actionString.length() - pos);
action->setText(actionString);
}
QAction *actionBefore = 0;
if (actions.count() > 0)
actionBefore = actions[0];
QAction *clearAction = new QAction(tr("Clear Shortcut"), menu);
menu->insertAction(actionBefore, clearAction);
menu->insertSeparator(actionBefore);
clearAction->setEnabled(!m_keySequence.isEmpty());
connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearShortcut()));
menu->exec(c->globalPos());
delete menu;
e->accept();
return true;
}
return QWidget::eventFilter(o, e);
}
示例5: eventFilter
bool ScalableWrapper::eventFilter(QObject* _object, QEvent* _event)
{
bool needShowMenu = false;
QPoint cursorPos = QCursor::pos();
switch (_event->type()) {
case QEvent::ContextMenu: {
QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(_event);
cursorPos = m_editor->viewport()->mapFromGlobal(contextMenuEvent->globalPos());
needShowMenu = true;
break;
}
case QEvent::MouseButtonPress: {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(_event);
if (mouseEvent->button() == Qt::RightButton) {
cursorPos = m_editor->viewport()->mapFromGlobal(mouseEvent->globalPos());
needShowMenu = true;
}
break;
}
default: {
break;
}
}
bool result = false;
//
// Если необходимо, то показываем контекстное меню в отдельном прокси элементе,
// предварительно вернув ему 100% масштаб
//
if (needShowMenu) {
QMenu* menu = m_editor->createStandardContextMenu();
QGraphicsProxyWidget* menuProxy = m_editorProxy->createProxyForChildWidget(menu);
const qreal antiZoom = 1. / m_zoomRange;
menuProxy->setScale(antiZoom);
menuProxy->setPos(QCursor::pos());
menu->exec();
delete menu;
//
// Событие перехвачено
//
result = true;
}
//
// Если нет, то стандартная обработка события
//
else {
result = QGraphicsView::eventFilter(_object, _event);
}
return result;
}
示例6: eventFilter
bool AddressWidget::eventFilter(QObject *object, QEvent *event)
{
if (object == m_bookmarkLabel && m_bookmarkLabel && event->type() == QEvent::MouseButtonPress)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
if (mouseEvent && mouseEvent->button() == Qt::LeftButton)
{
if (m_bookmarkLabel->isEnabled())
{
if (BookmarksManager::hasBookmark(getUrl()))
{
BookmarksManager::deleteBookmark(getUrl());
}
else
{
BookmarkInformation *bookmark = new BookmarkInformation();
bookmark->url = getUrl().toString(QUrl::RemovePassword);
bookmark->title = m_window->getTitle();
bookmark->type = UrlBookmark;
BookmarkPropertiesDialog dialog(bookmark, -1, this);
if (dialog.exec() == QDialog::Rejected)
{
delete bookmark;
}
}
updateBookmark();
}
return true;
}
}
if (object && event->type() == QEvent::ContextMenu)
{
QContextMenuEvent *contextMenuEvent = static_cast<QContextMenuEvent*>(event);
if (contextMenuEvent)
{
QMenu menu(this);
QAction *action = menu.addAction(tr("Remove This Icon"), this, SLOT(removeIcon()));
action->setData(object->objectName());
menu.exec(contextMenuEvent->globalPos());
contextMenuEvent->accept();
return true;
}
}
return QLineEdit::eventFilter(object, event);
}
示例7: eventFilter
bool Sidebar::eventFilter(QObject *obj, QEvent *ev)
{
if (ev->type() == QEvent::ContextMenu)
{
QContextMenuEvent *e = (QContextMenuEvent *) ev;
KMultiTabBarTab *bt = dynamic_cast<KMultiTabBarTab*>(obj);
if (bt)
{
//kDebug() << "Request for popup";
m_popupButton = bt->id();
ToolView *w = m_idToWidget[m_popupButton];
if (w)
{
KMenu *p = new KMenu (this);
if (!w->plugin.isNull()) {
Kate::PluginConfigPageInterface* pcpi=dynamic_cast<Kate::PluginConfigPageInterface*>(w->plugin.data());
if (pcpi) {
if (pcpi->configPages()>0)
p->addAction(i18n("Configure ..."))->setData(20);
}
}
p->addTitle(SmallIcon("view_remove"), i18n("Behavior"));
p->addAction(w->persistent ? KIcon("view-restore") : KIcon("view-fullscreen"),
w->persistent ? i18n("Make Non-Persistent") : i18n("Make Persistent") ) -> setData(10);
p->addTitle(SmallIcon("move"), i18n("Move To"));
if (position() != 0)
p->addAction(KIcon("go-previous"), i18n("Left Sidebar"))->setData(0);
if (position() != 1)
p->addAction(KIcon("go-next"), i18n("Right Sidebar"))->setData(1);
if (position() != 2)
p->addAction(KIcon("go-up"), i18n("Top Sidebar"))->setData(2);
if (position() != 3)
p->addAction(KIcon("go-down"), i18n("Bottom Sidebar"))->setData(3);
connect(p, SIGNAL(triggered(QAction*)),
this, SLOT(buttonPopupActivate(QAction*)));
p->exec(e->globalPos());
delete p;
return true;
}
}
}
示例8: eventFilter
bool LocationInformationWidget::eventFilter(QObject *, QEvent *ev)
{
if (ev->type() == QEvent::ContextMenu) {
QContextMenuEvent *ctx = (QContextMenuEvent *)ev;
QMenu contextMenu;
contextMenu.addAction(tr("Merge into current site"), this, SLOT(mergeSelectedDiveSites()));
contextMenu.exec(ctx->globalPos());
return true;
}
return false;
}
示例9: if
PlatformMouseEvent::PlatformMouseEvent(QInputEvent* event, int clickCount)
{
m_timestamp = WTF::currentTime();
QMouseEvent* me = 0;
switch (event->type()) {
case QEvent::MouseMove:
m_eventType = MouseEventMoved;
me = static_cast<QMouseEvent *>(event);
break;
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress:
m_eventType = MouseEventPressed;
me = static_cast<QMouseEvent *>(event);
break;
case QEvent::MouseButtonRelease:
m_eventType = MouseEventReleased;
me = static_cast<QMouseEvent *>(event);
break;
#ifndef QT_NO_CONTEXTMENU
case QEvent::ContextMenu: {
m_eventType = MouseEventPressed;
QContextMenuEvent* ce = static_cast<QContextMenuEvent*>(event);
m_position = IntPoint(ce->pos());
m_globalPosition = IntPoint(ce->globalPos());
m_button = RightButton;
break;
}
#endif // QT_NO_CONTEXTMENU
default:
m_eventType = MouseEventMoved;
}
if (me) {
m_position = IntPoint(me->pos());
m_globalPosition = IntPoint(me->globalPos());
if (me->button() == Qt::LeftButton || (me->buttons() & Qt::LeftButton))
m_button = LeftButton;
else if (me->button() == Qt::RightButton || (me->buttons() & Qt::RightButton))
m_button = RightButton;
else if (me->button() == Qt::MidButton || (me->buttons() & Qt::MidButton))
m_button = MiddleButton;
else
m_button = NoButton;
}
m_clickCount = clickCount;
m_shiftKey = (event->modifiers() & Qt::ShiftModifier);
m_ctrlKey = (event->modifiers() & Qt::ControlModifier);
m_altKey = (event->modifiers() & Qt::AltModifier);
m_metaKey = (event->modifiers() & Qt::MetaModifier);
}
示例10: eventFilter
bool LocationInformationWidget::eventFilter(QObject*, QEvent *ev)
{
if( ev->type() == QEvent::ContextMenu ) {
if (ui.diveSiteListView->selectionModel()->selectedIndexes().count() >= 2) {
QContextMenuEvent *ctx = (QContextMenuEvent*) ev;
QMenu contextMenu;
contextMenu.addAction(tr("Merge dive Sites"), this, SLOT(mergeSelectedDiveSites()));
contextMenu.exec(ctx->globalPos());
return true;
}
}
return false;
}
示例11: eventFilter
bool GoBackActionWidget::eventFilter(QObject *object, QEvent *event)
{
if (event->type() == QEvent::ContextMenu)
{
QContextMenuEvent *contextMenuEvent = dynamic_cast<QContextMenuEvent*>(event);
if (contextMenuEvent)
{
QAction *action = menu()->activeAction();
if (action && action->data().type() == QVariant::Int)
{
QMenu contextMenu(menu());
QAction *removeEntryAction = contextMenu.addAction(tr("Remove Entry"), NULL, NULL, QKeySequence(Qt::Key_Delete));
QAction *purgeEntryAction = contextMenu.addAction(tr("Purge Entry"), NULL, NULL, QKeySequence(Qt::ShiftModifier | Qt::Key_Delete));
QAction *selectedAction = contextMenu.exec(contextMenuEvent->globalPos());
if (selectedAction == removeEntryAction)
{
menu()->close();
getWindow()->getContentsWidget()->removeHistoryIndex(action->data().toInt());
}
else if (selectedAction == purgeEntryAction)
{
menu()->close();
getWindow()->getContentsWidget()->removeHistoryIndex(action->data().toInt(), true);
}
}
}
}
else if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = dynamic_cast<QKeyEvent*>(event);
if (keyEvent && keyEvent->key() == Qt::Key_Delete && getWindow())
{
QAction *action = menu()->activeAction();
if (action && action->data().type() == QVariant::Int)
{
menu()->close();
getWindow()->getContentsWidget()->removeHistoryIndex(action->data().toInt(), keyEvent->modifiers().testFlag(Qt::ShiftModifier));
}
}
}
return QObject::eventFilter(object, event);
}
示例12: eventFilter
bool FormSoftUpdate::eventFilter(QObject *watched, QEvent *event)
{
if(watched==ui->treeWidget)
{
if(event->type()==QEvent::ContextMenu)
{
QContextMenuEvent* dee = dynamic_cast<QContextMenuEvent*>(event);
QMenu *menu = new QMenu();
menu->addAction(removeCommand);
//menu->addAction(renameCommand);
menu->exec(dee->globalPos());
delete menu;
}
}
return QWidget::eventFilter(watched, event);
}
示例13: eventFilter
bool KeySequenceDialog::eventFilter(QObject *o, QEvent *e) {
if (o == ui.lineEdit && e->type() == QEvent::ContextMenu) {
QContextMenuEvent *c = static_cast<QContextMenuEvent *>(e);
QMenu *menu = new QMenu(ui.lineEdit);
QAction *clearAction = new QAction(tr("Clear"), menu);
menu->addAction(clearAction);
clearAction->setEnabled(!m_keySequence.isEmpty());
connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearShortcut()));
menu->exec(c->globalPos());
delete menu;
e->accept();
return true;
}
return QWidget::eventFilter(o, e);
}
示例14: eventFilter
bool Sidebar::eventFilter(QObject *obj, QEvent *ev)
{
if (ev->type()==QEvent::ContextMenu)
{
QContextMenuEvent *e = (QContextMenuEvent *) ev;
KMultiTabBarTab *bt = dynamic_cast<KMultiTabBarTab*>(obj);
if (bt)
{
kdDebug()<<"Request for popup"<<endl;
m_popupButton = bt->id();
ToolView *w = m_idToWidget[m_popupButton];
if (w)
{
KPopupMenu *p = new KPopupMenu (this);
p->insertTitle(SmallIcon("view_remove"), i18n("Behavior"), 50);
p->insertItem(w->persistent ? SmallIconSet("window_nofullscreen") : SmallIconSet("window_fullscreen"), w->persistent ? i18n("Make Non-Persistent") : i18n("Make Persistent"), 10);
p->insertTitle(SmallIcon("move"), i18n("Move To"), 51);
if (position() != 0)
p->insertItem(SmallIconSet("back"), i18n("Left Sidebar"),0);
if (position() != 1)
p->insertItem(SmallIconSet("forward"), i18n("Right Sidebar"),1);
if (position() != 2)
p->insertItem(SmallIconSet("up"), i18n("Top Sidebar"),2);
if (position() != 3)
p->insertItem(SmallIconSet("down"), i18n("Bottom Sidebar"),3);
connect(p, SIGNAL(activated(int)),
this, SLOT(buttonPopupActivate(int)));
p->exec(e->globalPos());
delete p;
return true;
}
}
}
示例15: event
bool SessionListWidget::event(QEvent *event)
{
#ifndef QUTIM_MOBILE_UI
if (event->type() == QEvent::ToolTip) {
if (QHelpEvent *help = static_cast<QHelpEvent*>(event)) {
int index = indexAt(help->pos()).row();
if (index != -1) {
ChatUnit *unit = session(index)->getUnit();
ToolTip::instance()->showText(help->globalPos(), unit, this);
return true;
}
}
} else if (event->type() == QEvent::DragEnter) {
QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent*>(event);
if (const MimeObjectData *data = qobject_cast<const MimeObjectData*>(dragEvent->mimeData())) {
ChatUnit *u = qobject_cast<ChatUnit*>(data->object());
if (u)
dragEvent->acceptProposedAction();
}
return true;
} else if (event->type() == QEvent::Drop) {
QDropEvent *dropEvent = static_cast<QDropEvent*>(event);
if (const MimeObjectData *mimeData
= qobject_cast<const MimeObjectData*>(dropEvent->mimeData())) {
if (ChatUnit *u = qobject_cast<ChatUnit*>(mimeData->object())) {
ChatLayerImpl::get(u,true)->activate();
dropEvent->setDropAction(Qt::CopyAction);
dropEvent->accept();
return true;
}
}
} else
#endif
if (event->type() == QEvent::ContextMenu) {
QContextMenuEvent *ev = static_cast<QContextMenuEvent*>(event);
ChatSessionImpl *s = session(row(itemAt(ev->pos())));
if(s) {
s->unit()->showMenu(ev->globalPos());
return true;
}
}
return QListWidget::event(event);
}