【问题标题】:Queueing of global event if Qt 5 event loop is paused如果 Qt 5 事件循环暂停,则全局事件排队
【发布时间】:2015-12-20 06:31:28
【问题描述】:

在某些移动系统上,当应用程序进入后台时,Qt 主循环会暂停(它也可能会被终止,但这不是这个问题的一部分)。

如果后台服务、传感器等在不活动时发布到事件队列会发生什么?发布事件如下所示:

QCoreApplication::postEvent(QCoreApplication::instance(), event);

事件是否被缓存,缓存事件的数量是否有限(内存除外)?

问候,

【问题讨论】:

    标签: qt events qt5 qcoreapplication


    【解决方案1】:

    当主线程暂停时,事件应该正确排队。来自source code postEvent

    Adds the event \a event, with the object \a receiver as the
    receiver of the event, to an event queue and returns immediately.
    
    When control returns to the main event loop, all events that are
    stored in the queue will be sent using the notify() function.
    

    【讨论】:

      猜你喜欢
      • 2021-08-24
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-18
      • 2010-12-19
      • 2014-10-31
      相关资源
      最近更新 更多