Update QWebElement from different threads
-
Hi guys... I need to update a QWebElement from different threads... Imagine that I have the following statement:
QString htmlElemCode = "<p>Hello World</p>"; QWebElement elem = webFrame->findFirtsElement("#body_div"); elem.appendInside(htmlElemCode);
well, I need to run
elem.appendInside(htmlElemCode);
in a thread different than the main thread. I had defined this piece of code inside one slot, which I need to call it in a different threads, not only from the main thread. The problem come when I try to call the slot from a thread different than the main thread, because the GUI doesn't update it's html content... however, if I call the slot from the main thread, I can see a success result on my html content, updating the html elements as I wish.
My main goal is update my html content dynamically using a javascript functions defined on my html code, which let me add some rows and columns to my html tables, but, I need to do this using various threads...
is that possible ??? what is the best way to do that ??
regards
-
HI,
The usual technique is to use signals and slots. Have a signal emitted with your changes from your worker object in your thread and a slot in the widget which should do the processing.
Hope it helps
-
HI,
The usual technique is to use signals and slots. Have a signal emitted with your changes from your worker object in your thread and a slot in the widget which should do the processing.
Hope it helps
@SGaist
In the mailing list, Thiago have already answered this question in his typical brusque manner, although as usual he's spot on. ;)So to quote him here for completeness:
is that possible ??? what is the best way to do that
It's not possible to modify any UI from outside the UI thread.
You need to sync back to the main thread via a queued connection or via an
event and do that from the main thread.Thiago Macieira
-
Concise and pragmatic would be a better definition :)
He's a nice guy