how to access the axwidget in qthread or qconcurrent



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


  • Qt Champions 2016

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



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


  • Qt Champions 2016

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



  • @kshegunov
    thanks for ur info.....



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.