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。

  • 相关阅读:
    Eclipse使用
    java基础
    js冒泡排序与二分法查找
    js数组
    html练习
    html5表单
    html5标签
    问题总结
    学习目标
    项目总结
  • 原文地址:https://www.cnblogs.com/cute/p/2563643.html
Copyright © 2011-2022 走看看