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.
  • A Offline
    A Offline
    Ahti
    wrote on 3 Jun 2019, 07:54 last edited by Ahti 6 Mar 2019, 07:55
    #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

    J 1 Reply Last reply 3 Jun 2019, 07:59
    0
    • A Ahti
      3 Jun 2019, 07:54

      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 ?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 3 Jun 2019, 07:59 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

      A 1 Reply Last reply 4 Jun 2019, 05:35
      1
      • J jsulm
        3 Jun 2019, 07:59

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

        A Offline
        A Offline
        Ahti
        wrote on 4 Jun 2019, 05:35 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

        J 1 Reply Last reply 4 Jun 2019, 05:38
        0
        • A Ahti
          4 Jun 2019, 05:35

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

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 4 Jun 2019, 05:38 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

          A 1 Reply Last reply 4 Jun 2019, 08:23
          0
          • J jsulm
            4 Jun 2019, 05:38

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

            closes it immediately.

            Does it close if you don't call CoInitializeEx?

            A Offline
            A Offline
            Ahti
            wrote on 4 Jun 2019, 08:23 last edited by
            #5

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

            what is a signature ?? Lol

            J 1 Reply Last reply 4 Jun 2019, 08:25
            0
            • A Ahti
              4 Jun 2019, 08:23

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

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 4 Jun 2019, 08:25 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

              A 1 Reply Last reply 4 Jun 2019, 08:50
              0
              • J jsulm
                4 Jun 2019, 08:25

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

                A Offline
                A Offline
                Ahti
                wrote on 4 Jun 2019, 08:50 last edited by Ahti 6 Apr 2019, 08:51
                #7

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

                what is a signature ?? Lol

                J 1 Reply Last reply 4 Jun 2019, 08:54
                0
                • A Ahti
                  4 Jun 2019, 08:50

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

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 4 Jun 2019, 08:54 last edited by jsulm 6 Apr 2019, 08:54
                  #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

                  A 1 Reply Last reply 4 Jun 2019, 09:12
                  0
                  • J jsulm
                    4 Jun 2019, 08:54

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

                    A Offline
                    A Offline
                    Ahti
                    wrote on 4 Jun 2019, 09:12 last edited by
                    #9

                    @jsulm visual studio ?

                    what is a signature ?? Lol

                    J 1 Reply Last reply 4 Jun 2019, 09:14
                    0
                    • A Ahti
                      4 Jun 2019, 09:12

                      @jsulm visual studio ?

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 4 Jun 2019, 09:14 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

                      1/10

                      3 Jun 2019, 07:54

                      • Login

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