Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. India
  4. how to access the axwidget in qthread or qconcurrent
Forum Updated to NodeBB v4.3 + New Features

how to access the axwidget in qthread or qconcurrent

Scheduled Pinned Locked Moved Solved India
6 Posts 2 Posters 3.4k Views 2 Watching
  • 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.
  • -AVM- Offline
    -AVM- Offline
    -AVM
    wrote on last edited by
    #1

    ->i want access the axwidget in qthread but it gives assert failure....
    ->if i create axwidget in qthread it gives error like this
    ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file kernel\qwidget.cpp, line 1126
    ->if i create a axwidget in main thread and i tried to a access the object from new thread again it gives error like this
    assert failure in qcoreapplication::sendevent: "cannot send events to objects owned by a different thread

    **here is my code **
    viewstack::viewstack(QWidget *parent) : QDialog(parent)
    {
    excel = new QAxWidget("Excel.Application", 0);
    QtConcurrent::run(this,&viewstack::run);
    }
    void viewstack::run()
    {
    qDebug()<<"thread running...."
    excel->setProperty("Visible", true);
    }
    in this code qdebug is executing....

    kshegunovK 1 Reply Last reply
    0
    • -AVM- -AVM

      ->i want access the axwidget in qthread but it gives assert failure....
      ->if i create axwidget in qthread it gives error like this
      ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file kernel\qwidget.cpp, line 1126
      ->if i create a axwidget in main thread and i tried to a access the object from new thread again it gives error like this
      assert failure in qcoreapplication::sendevent: "cannot send events to objects owned by a different thread

      **here is my code **
      viewstack::viewstack(QWidget *parent) : QDialog(parent)
      {
      excel = new QAxWidget("Excel.Application", 0);
      QtConcurrent::run(this,&viewstack::run);
      }
      void viewstack::run()
      {
      qDebug()<<"thread running...."
      excel->setProperty("Visible", true);
      }
      in this code qdebug is executing....

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @-AVM
      Hello,

      i want access the axwidget in qthread

      You can't!
      However this thread might be helpful:
      http://forum.qt.io/topic/67437/gui-operations-across-threads-again/2

      Kind regards.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • -AVM- Offline
        -AVM- Offline
        -AVM
        wrote on last edited by
        #3

        @kshegunov said:

        any other ways to create axwidgets in thread.....
        my application is like this the main thread is writting the data continously in excel.....and the qthread need to read continously......

        one more question how to access the axobjects in thread....

        kshegunovK 1 Reply Last reply
        0
        • -AVM- -AVM

          @kshegunov said:

          any other ways to create axwidgets in thread.....
          my application is like this the main thread is writting the data continously in excel.....and the qthread need to read continously......

          one more question how to access the axobjects in thread....

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @-AVM
          I don't know about AX objects (I don't actively develop on windows and you're better off asking MSDN that), but widgets are not thread-safe, nor reentrant. You will not be able to access them concurrently at all. You must serialize the accesses to the widgets through the event loop, there's no other way.

          Read and abide by the Qt Code of Conduct

          -AVM- 1 Reply Last reply
          1
          • kshegunovK kshegunov

            @-AVM
            I don't know about AX objects (I don't actively develop on windows and you're better off asking MSDN that), but widgets are not thread-safe, nor reentrant. You will not be able to access them concurrently at all. You must serialize the accesses to the widgets through the event loop, there's no other way.

            -AVM- Offline
            -AVM- Offline
            -AVM
            wrote on last edited by
            #5

            @kshegunov
            thanks for ur info.....

            1 Reply Last reply
            0
            • -AVM- Offline
              -AVM- Offline
              -AVM
              wrote on last edited by
              #6

              I Tried QAxObject instead of QAxWidgetand CoInitialize() there..... it works fine in another thread.

              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