Concept of threads when running a project in Qt
-
Hi
I am working on project that needs to initialize COM library. I have copy pasted the code for that into my qt project .COM Initialization code :
hres = CoInitializeEx(0, COINIT_MULTITHREADED); if (FAILED(hres)){ cout << "Failed to initialize COM library. Error code = 0x" << hex << hres << endl; return 1; }
But when I run my project I get this error: Failed to initialize COM library. Error code = 0x80010106. I googled the error code and it reflects to this RPC_E_CHANGED_MODE. So after reading about when is ConInitializeEx returning this error and it turns out it has to something to do with threads. As being a newbie to Qt I know nothing about Qt threads.
Can anyone explain me what is going on ? and how to fix it ?
-
@Ahti This is from the link you posted:
"A previous call to CoInitializeEx specified the concurrency model for this thread as multithread apartment (MTA). This could also indicate that a change from neutral-threaded apartment to single-threaded apartment has occurred. "
Did you call CoInitializeEx already before with other parameters? Did you create any threads in your app? -
@jsulm No I didn't called it before that is the only time I am calling that function. And no I didn't created any thread morever I don't know if qt creates thread on its own when running the project/application. The movement I run my project/application qt displays the app window and then closes it immediately.
-
@Ahti said in Concept of threads when running a project in Qt:
closes it immediately.
Does it close if you don't call CoInitializeEx?
-
@Ahti said in Concept of threads when running a project in Qt:
and what is non qt project
Well, a C++ project which does not use Qt at all?
QtCreator even can create one.