本文整理汇总了C++中QCoreApplication::postEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ QCoreApplication::postEvent方法的具体用法?C++ QCoreApplication::postEvent怎么用?C++ QCoreApplication::postEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCoreApplication
的用法示例。
在下文中一共展示了QCoreApplication::postEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: observe
void ConnectorObserver::observe(const stromx::runtime::Connector& connector,
const stromx::runtime::DataContainer & /*oldData*/,
const stromx::runtime::DataContainer & newData,
const stromx::runtime::Thread* const /*thread*/) const
{
// First check if there have been too many events recently. If this is the
// case return and give the GUI the chance to handle the remaining events.
if (! gScheduler.schedule())
return;
// consider only the new (= current) connector value
const stromx::runtime::DataContainer & data = newData;
QCoreApplication* application = QCoreApplication::instance();
OperatorModel::ConnectorType type = connector.type() == stromx::runtime::Connector::INPUT ?
OperatorModel::INPUT : OperatorModel::OUTPUT;
ConnectorOccupyEvent* occupyEvent = new ConnectorOccupyEvent(type, connector.id(), data.empty() ? false : true);
application->postEvent(m_receiver, occupyEvent);
// Next the actual data is observed:
// First make sure the data is not empty.
if(data.empty())
return;
// If receivers are connected to the respective signal of OperatorModel
// the member m_observeData is true. Here we obtain the flag in a thread-safe
// way.
bool observeData = false;
{
QMutexLocker lock(&m_mutex);
observeData = m_observeData;
}
// The data must be observed only if the the flag is true and the connector
// is an input (observation of outputs is not supported because it can always
// be achieved by observing the corresponding input).
if(observeData && type == OperatorModel::INPUT)
{
// get a read access to the data (this might take a while)
stromx::runtime::ReadAccess access(data);
// send an event with the data and the access to the Qt GUI loop
ConnectorDataEvent* dataEvent = new ConnectorDataEvent(type, connector.id(), access);
application->postEvent(m_receiver, dataEvent);
}
}