本文整理汇总了C++中QCoreApplication::installEventFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ QCoreApplication::installEventFilter方法的具体用法?C++ QCoreApplication::installEventFilter怎么用?C++ QCoreApplication::installEventFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCoreApplication
的用法示例。
在下文中一共展示了QCoreApplication::installEventFilter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qtnStartInplaceEdit
bool qtnStartInplaceEdit(QWidget* editor)
{
if (!editor)
return false;
if (g_inplaceEditor)
{
Q_ASSERT(false);
qtnStopInplaceEdit();
}
QCoreApplication* app = QCoreApplication::instance();
if (!app)
{
Q_ASSERT(false);
return false;
}
g_inplaceEditor = editor;
g_inplaceEditorHandler = new QtnInplaceEditorHandler();
// move focus to editor
if (QApplication::focusWidget() != g_inplaceEditor->focusWidget())
g_inplaceEditor->setFocus();
// connect to editor destroyed signal
QObject::connect( g_inplaceEditor, &QObject::destroyed
, g_inplaceEditorHandler, &QtnInplaceEditorHandler::OnEditorDestroyed);
// install application event filter
app->installEventFilter(g_inplaceEditorHandler);
return true;
}
示例2: locker
QApplicationActivityObserver * QApplicationActivityObserver::instance()
{
static QMutex mymutex;
static QScopedPointer<QApplicationActivityObserver> instance;
QMutexLocker locker(&mymutex);
// Creating instance
if (instance.isNull())
{
instance.reset(new QApplicationActivityObserver());
}
// Installing event filter
static bool installed_filter = false;
if (!installed_filter)
{
QCoreApplication * app = QCoreApplication::instance();
if (app)
{
app->installEventFilter(instance.data());
installed_filter = true;
qDebug()<<__FUNCTION__<<"Successfully installed event filter.";
}
else
{
qWarning()<<__FUNCTION__<<"installing event filter failed because QCoreApplication instance doesn't exist, will try later.";
}
}
return instance.data();
}
示例3: toolOnSetup
void grabUVContext::toolOnSetup( MEvent &event )
{
MPxTexContext::toolOnSetup( event );
QCoreApplication *app = qApp;
app->installEventFilter(this);
}