Running qt as a thread from another application written in C language
I have a query. Can we run a QT application as thread from another process? if we can, anybody can tell me开发者_JS百科 how??? I have an application written in C language. Some how I need to run the Qt application as a thread from that process. This is because I have some values to be passed to Qt application. I am trying to pass these as arguments to Qt application so as to use these arguments in my window.
You are mixing your terminology.
In Linux you normally use fork/exec to control an external process. A thread is an execution context within your own process. With the fork/exec method you can supply command-line arguments and also create pipe()
handles to capture stdin/stdout.
You could also link in a Qt application directly into your own.
extern "C" int foo_main (int argc, char ** argv)
{
QApplication app (argc, argv);
// rest as normal
}
You can call foo_main from some thread in your C program and it will work providing you don't muck around with other GUI stuff as well.
精彩评论