Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - Calling an event function in a QT thread from a QNX thread.: Page 1 of 6 (6 Items)
   
Calling an event function in a QT thread from a QNX thread.  
Hello,

I have a 'AM335x EVM board' and have downloaded the BSP “Texas Instruments AM335x EVM” project. I use QNX 6.5.0 and 
Momentics 4.7.0.

 I have an issue that I don’t know how to call event/message functions inside the “QT thread” from a QNX thread in my
 QNX application.

In main I create a thread for receiving can messages.  When I have received a can message I would like to send an event/
message/signal to my “myqtclass” event function or another function inside the object. I end up in the function 
myqtcalss::event but I still execute in the “qnx function thread” not the “QT thread”. Because of this I receive an 
error message from QT. I would like to send an event/message/signal so the “QT thread” execute it. Do you have any 
suggestion how to do this?

Example code:

*********************

main.c

MyQTClass *myqtcalss;

int main(int argc, char **argv)
{
   // Creating QNX can receive function thread
   …

   QApplication app(argc, argv);

   // QT code
   …
   myqtcalss = new MyQTClass; 
   …

   return app.exec();
}

*********************

myclass.cpp

bool myqtcalss::event(QEvent *event)
{
   // Here I would like to end up in the “QT thread”
}

*********************

qnx.c

void QNX_thread_function( void *pvParameters )
{
   // Code that executes when a can message is received
   QEvent event((QEvent::Type)1001);
   QApplication::sendEvent(myqtclass, &event);
}

*********************