当前位置: 首页>>代码示例>>C++>>正文


C++ QCoreApplication::postEvent方法代码示例

本文整理汇总了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);
    }
}
开发者ID:roteroktober,项目名称:stromx-studio,代码行数:46,代码来源:ConnectorObserver.cpp


注:本文中的QCoreApplication::postEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。