Qt World Summit: Register Today!

Thread in qtbrowser application

  • Hi,
    I have a browser application in qt .I need to run a thread in parallel to the browser taking the screenshot of the browser and sent to another pc. I used to capture the frame of webpage by rendering the mainframe of the webpage to an image. For that i need to give an input to the the thread ie, webview ' s object .How can i give the pass the object to the thread.?

  • Hi, First of all, you can't use GUI elements in a different thread then the main thread. One could consider to 'copy' the webview object, but then again, the copy of a QObject is forbidden because very simple, you can't copy children / parent relations.
    What I would try is to generate the QImage like you said and then pass it to the already running thread calling a 'send' slot in that Thread object. The slot should receive a copy of the image so be threadsafe.
    If that doesn't work, try to register a new type (Q_REGISTER_METATYPE) of a class (CAN'T BE A QOBJECT DERIVED CLASS as explained before) that holds all needed data to be transferred.

Log in to reply