Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Concept of threads when running a project in Qt
Forum Updated to NodeBB v4.3 + New Features

Concept of threads when running a project in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • AhtiA Offline
    AhtiA Offline
    Ahti
    wrote on last edited by Ahti
    #1

    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 ?

    what is a signature ?? Lol

    jsulmJ 1 Reply Last reply
    0
    • AhtiA Ahti

      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 ?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      AhtiA 1 Reply Last reply
      1
      • jsulmJ jsulm

        @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?

        AhtiA Offline
        AhtiA Offline
        Ahti
        wrote on last edited by
        #3

        @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.

        what is a signature ?? Lol

        jsulmJ 1 Reply Last reply
        0
        • AhtiA Ahti

          @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.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Ahti said in Concept of threads when running a project in Qt:

          closes it immediately.

          Does it close if you don't call CoInitializeEx?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          AhtiA 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Ahti said in Concept of threads when running a project in Qt:

            closes it immediately.

            Does it close if you don't call CoInitializeEx?

            AhtiA Offline
            AhtiA Offline
            Ahti
            wrote on last edited by
            #5

            @jsulm No it doesn't close if I don't call CoInitializeEx.

            what is a signature ?? Lol

            jsulmJ 1 Reply Last reply
            0
            • AhtiA Ahti

              @jsulm No it doesn't close if I don't call CoInitializeEx.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Ahti Did you try to use CoInitializeEx in a non Qt project to see how it behaves?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              AhtiA 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Ahti Did you try to use CoInitializeEx in a non Qt project to see how it behaves?

                AhtiA Offline
                AhtiA Offline
                Ahti
                wrote on last edited by Ahti
                #7

                @jsulm and what is non qt project ? Can you give example

                what is a signature ?? Lol

                jsulmJ 1 Reply Last reply
                0
                • AhtiA Ahti

                  @jsulm and what is non qt project ? Can you give example

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by jsulm
                  #8

                  @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.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  AhtiA 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @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.

                    AhtiA Offline
                    AhtiA Offline
                    Ahti
                    wrote on last edited by
                    #9

                    @jsulm visual studio ?

                    what is a signature ?? Lol

                    jsulmJ 1 Reply Last reply
                    0
                    • AhtiA Ahti

                      @jsulm visual studio ?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Ahti Why Visual Studio? You can use QtCreator or even a text editor to create plain C++ projects.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved