Benjamin
11th November 2008, 08:36
Hi all,
I am having problems with my GUI interface. It constantly keeps locking for a few seconds. My application is not a pure cpp application it has event handling mechanism which is implemented in C. From main function in C code I create guimain thread which than runs and send events to C code.
Main function in C looks like this:
int main(int argc, char *argv[])
{
.......do some stuff......
gui_init(argc, argv, (void*)&gui_sync);
while(!device_shutdown)
{
process_message_queues(5);
}
pthread_join( gui_t, NULL);
return 0;
}
CPP code
EXT_C int gui_init( int argc, char *argv[], void *gui_sync)
{
myargc = argc;
myargv = argv;
pthread_attr_init(&gui_attr);
pthread_create(&gui_t, &gui_attr, guimain, (void *)gui_sync);
return 0;
}
void *guimain( void* lpParam )
{
char *defaultargs[2];
struct gui_sync_t *sync = (struct gui_sync_t*)lpParam;
QApplication app( myargc, myargv );
main1=new formMain;
main1->setGeometry(0,0,240,320);
main1->show();
setTargetWidget(main1);
app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
sync->ready=1;
return (void*)app.exec();
}
When I run this application on my device I get following warning:
WARNING: QApplication was not created in the main() thread.
Does anyone has any idea?
Tnx,
Benjamin
I am having problems with my GUI interface. It constantly keeps locking for a few seconds. My application is not a pure cpp application it has event handling mechanism which is implemented in C. From main function in C code I create guimain thread which than runs and send events to C code.
Main function in C looks like this:
int main(int argc, char *argv[])
{
.......do some stuff......
gui_init(argc, argv, (void*)&gui_sync);
while(!device_shutdown)
{
process_message_queues(5);
}
pthread_join( gui_t, NULL);
return 0;
}
CPP code
EXT_C int gui_init( int argc, char *argv[], void *gui_sync)
{
myargc = argc;
myargv = argv;
pthread_attr_init(&gui_attr);
pthread_create(&gui_t, &gui_attr, guimain, (void *)gui_sync);
return 0;
}
void *guimain( void* lpParam )
{
char *defaultargs[2];
struct gui_sync_t *sync = (struct gui_sync_t*)lpParam;
QApplication app( myargc, myargv );
main1=new formMain;
main1->setGeometry(0,0,240,320);
main1->show();
setTargetWidget(main1);
app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
sync->ready=1;
return (void*)app.exec();
}
When I run this application on my device I get following warning:
WARNING: QApplication was not created in the main() thread.
Does anyone has any idea?
Tnx,
Benjamin