zoukankan      html  css  js  c++  java
  • QObject

    QObject Class Reference

     
    void QObject::moveToThread ( QThread * targetThread )

    Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the targetThread.

    To move an object to the main thread, use QApplication::instance() to retrieve a pointer to the current application, and then use QApplication::thread() to retrieve the thread in which the application lives. For example:

     myObject->moveToThread(QApplication::instance()->thread());

    If targetThread is zero, all event processing for this object and its children stops.

    Note that all active timers for the object will be reset. The timers are first stopped in the current thread and restarted (with the same interval) in the targetThread. As a result, constantly moving an object between threads can postpone timer events indefinitely.

    A QEvent::ThreadChange event is sent to this object just before the thread affinity is changed. You can handle this event to perform any special processing. Note that any new events that are posted to this object will be handled in the targetThread.

    Warning: This function is not thread-safe; the current thread must be same as the current thread affinity. In other words, this function can only "push" an object from the current thread to another thread, it cannot "pull" an object from any arbitrary thread to the current thread.

    See also thread().

    QApplication::instance()->thread()取得main thread,然后用To move an object to the main thread。

    active timers for the object will be reset。

  • 相关阅读:
    RAM disk
    将2个物理磁盘做成4个逻辑卷
    LVM——基本概念
    服务器CPU架构演变过程
    IBM XIV
    011——一些貌似高逼格的词汇
    010——存储系统架构演变
    010——集群化
    009——虚拟化
    008——协议融合
  • 原文地址:https://www.cnblogs.com/cute/p/2563643.html
Copyright © 2011-2022 走看看