class ColorChangeEvent : public QCustomEvent { public: ColorChangeEvent( QColor color ) : QCustomEvent( ), c( color ) {} QColor color() const { return c; } private: QColor c; }; // To send an event of this custom event type: ColorChangeEvent* ce = ne
Qt3中可以直接向线程发送消息 QThread::postEventQ4中已不支持为了模拟向线程发送消息,可以通过QObject::moveToThread后,然后再向这个QObject发送消息 object = new QObject;object.moveToThread(thread);QCoreApplication::postEvent(object, new Event);