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. Can I get QImage of a QWebView from another thread?

Can I get QImage of a QWebView from another thread?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.7k 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.
  • C Offline
    C Offline
    chiyuwang
    wrote on last edited by
    #1

    I am trying to get pixels from QWebView in my application regularly, like every 30 f/s, and I dont want to block the mainthread, so QWebView can run normallly. But I got following message, which seems that it has to be in mainthread.

    Is it possible that I create another process and use it only for getting pixels from QWebView, so that QWebView will be in Mainthread and wont affect the application's main thread, could it be a solution? (I have not done anything like it before, the concept may not right.)

    Is there any other solution? Thank you.

    ASSERTION FAILED: isMainThread()
    c:\work\build\qt5_workdir\w\s\qtwebkit\source\webcore\dom\Document.cpp(1851) : WebCore::Document::updateStyleIfNeeded
    ...

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi,
      All GUI elements need to be in the MainThread, that is why you get the assertion. GUI (widgets) are not thread safe!

      Working with different threads is possible, but have a signal be emitted by the QWebView (Mainthread) when new data is available and catch that in a slot in your handling thread.
      If both application main thread and QWebView are using GUI elements it not valid to do it multithreading!

      Greetz, Jeroen

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chiyuwang
        wrote on last edited by
        #3

        Thank you for your quick reply.

        Would you please tell me which signal I should use? There is no event that can tell me that pixels has been changed in QWebView.

        Or Is there any class from qwebkit that is not GUI element and I can use it to get bitmap basicly.

        [quote author="Jeroentje@home" date="1398679981"]Hi,
        All GUI elements need to be in the MainThread, that is why you get the assertion. GUI (widgets) are not thread safe!

        Working with different threads is possible, but have a signal be emitted by the QWebView (Mainthread) when new data is available and catch that in a slot in your handling thread.
        If both application main thread and QWebView are using GUI elements it not valid to do it multithreading![/quote]

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

          QWebView is a Widget, so no, you can't use multitheading or place it outside your mainthread.
          The biggest question now is, what do you need, what do you want? Only to give the best answer to your problem, not just a solution for this particular question.

          Greetz, Jeroen

          1 Reply Last reply
          0
          • C Offline
            C Offline
            chiyuwang
            wrote on last edited by
            #5

            What I mainly need is to get pixel values from QWebView and I will send them over the network to other computers with good framerate.

            Since getting pixels block the main thread, it will interfere UI usage, for exmaple, if I open youtube page, it playback will be very stuttering, because of the code which tries to get pixels blocks it.

            [quote author="Jeroentje@home" date="1398681097"]QWebView is a Widget, so no, you can't use multitheading or place it outside your mainthread.
            The biggest question now is, what do you need, what do you want? Only to give the best answer to your problem, not just a solution for this particular question. [/quote]

            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