1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <myThread.h>
int main(int argc, char* argv[])
{
bool thread_send_signal = false;
myThread *pThread = new myThread(thread_send_signal);
pThread->start();
QApplication app(argc, argv);
myButton *pButton= new myButton("test");
pButton->resize(75, 30);
qRegisterMetaType<myTest>("myTest");
if (pThread->m_sender)
{
QObject::connect(pThread, SIGNAL(mySignal( const myTest & )), pButton, SLOT(mySlot( const myTest & )));
// QObject::connect(pThread->m_pObj_BeforStart, SIGNAL(mySignal( const myTest & )),pButton , SLOT(mySlot( const myTest & )));
// QObject::connect(pThread->m_pObj_AfterSTart, SIGNAL(mySignal( const myTest & )),pButton , SLOT(mySlot( const myTest & )));
}
else
{
QObject::connect(pButton, SIGNAL(mySignal( const myTest & )), pThread, SLOT(mySlot( const myTest & )));
//QObject::connect(pButton, SIGNAL(mySignal( const myTest & )), pThread, SLOT(mySlot( const myTest & )),Qt::QueuedConnection);
//QObject::connect(pButton, SIGNAL(mySignal( const myTest & )), pThread->m_pObj_BeforStart, SLOT(mySlot( const myTest & )));
//QObject::connect(pButton, SIGNAL(mySignal( const myTest & )), pThread->m_pObj_AfterSTart, SLOT(mySlot( const myTest & )));
}
pButton->show();
return app.exec();
} |