本文整理汇总了C++中QContextMenuEvent::accept方法的典型用法代码示例。如果您正苦于以下问题:C++ QContextMenuEvent::accept方法的具体用法?C++ QContextMenuEvent::accept怎么用?C++ QContextMenuEvent::accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContextMenuEvent
的用法示例。
在下文中一共展示了QContextMenuEvent::accept方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool QToolBoxHelper::eventFilter(QObject *watched, QEvent *event)
{
switch (event->type()) {
case QEvent::ChildPolished:
// Install on the buttons
if (watched == m_toolbox) {
QChildEvent *ce = static_cast<QChildEvent *>(event);
if (!qstrcmp(ce->child()->metaObject()->className(), "QToolBoxButton"))
ce->child()->installEventFilter(this);
}
break;
case QEvent::ContextMenu:
if (watched != m_toolbox) {
// An action invoked from the passive interactor (ToolBox button) might
// cause its deletion within its event handler, triggering a warning. Re-post
// the event to the toolbox.
QContextMenuEvent *current = static_cast<QContextMenuEvent *>(event);
QContextMenuEvent *copy = new QContextMenuEvent(current->reason(), current->pos(), current-> globalPos(), current->modifiers());
QApplication::postEvent(m_toolbox, copy);
current->accept();
return true;
}
break;
case QEvent::MouseButtonRelease:
if (watched != m_toolbox)
if (QDesignerFormWindowInterface *fw = QDesignerFormWindowInterface::findFormWindow(m_toolbox)) {
fw->clearSelection();
fw->selectWidget(m_toolbox, true);
}
break;
default:
break;
}
return QObject::eventFilter(watched, event);
}
示例2: 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);
}
示例3: event
bool GoBackActionWidget::event(QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick || event->type() == QEvent::Wheel)
{
QList<GesturesManager::GesturesContext> contexts;
contexts << GesturesManager::ToolBarGesturesContext << GesturesManager::GenericGesturesContext;
if (GesturesManager::startGesture(this, event, contexts))
{
return true;
}
}
if (event->type() == QEvent::ContextMenu)
{
QContextMenuEvent *contextMenuEvent = static_cast<QContextMenuEvent*>(event);
if (contextMenuEvent)
{
if (contextMenuEvent->reason() == QContextMenuEvent::Mouse)
{
contextMenuEvent->accept();
return true;
}
event->accept();
Window *window = getWindow();
QMenu menu(this);
menu.addAction(window ? window->getContentsWidget()->getAction(ActionsManager::ClearTabHistoryAction) : ActionsManager::getAction(ActionsManager::ClearTabHistoryAction, this));
menu.addAction(window ? window->getContentsWidget()->getAction(ActionsManager::PurgeTabHistoryAction) : ActionsManager::getAction(ActionsManager::PurgeTabHistoryAction, this));
ToolBarWidget *toolBar = qobject_cast<ToolBarWidget*>(parentWidget());
if (toolBar)
{
menu.addSeparator();
menu.addActions(ToolBarWidget::createCustomizationMenu(toolBar->getIdentifier(), QList<QAction*>(), &menu)->actions());
}
menu.exec(contextMenuEvent->globalPos());
return true;
}
return false;
}
if (event->type() == QEvent::ToolTip)
{
QHelpEvent *helpEvent = dynamic_cast<QHelpEvent*>(event);
if (helpEvent)
{
const QVector<QKeySequence> shortcuts = ActionsManager::getActionDefinition(ActionsManager::GoBackAction).shortcuts;
QString toolTip = text() + (shortcuts.isEmpty() ? QString() : QLatin1String(" (") + shortcuts.at(0).toString(QKeySequence::NativeText) + QLatin1Char(')'));
if (getWindow())
{
const WindowHistoryInformation history = getWindow()->getContentsWidget()->getHistory();
if (!history.entries.isEmpty() && history.index > 0)
{
QString title = history.entries.at(history.index - 1).title;
title = (title.isEmpty() ? tr("(Untitled)") : title.replace(QLatin1Char('&'), QLatin1String("&&")));
toolTip = title + QLatin1String(" (") + text() + (shortcuts.isEmpty() ? QString() : QLatin1String(" - ") + shortcuts.at(0).toString(QKeySequence::NativeText)) + QLatin1Char(')');
}
}
QToolTip::showText(helpEvent->globalPos(), toolTip);
}
return true;
}
return ActionWidget::event(event);
}
示例4: 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 != this && 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;
}
}
if (object == this && event->type() == QEvent::KeyPress && m_window)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Escape)
{
const QUrl url = m_window->getUrl();
if (text().trimmed().isEmpty() || text().trimmed() != url.toString())
{
setText((url.scheme() == QLatin1String("about") && m_window->isUrlEmpty()) ? QString() : url.toString());
if (!text().trimmed().isEmpty() && SettingsManager::getValue(QLatin1String("AddressField/SelectAllOnFocus")).toBool())
{
QTimer::singleShot(0, this, SLOT(selectAll()));
}
}
else
{
m_window->setFocus();
}
}
}
return QLineEdit::eventFilter(object, event);
}