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. QThreadPool , QRunnable and objects that need to be created in main thread
Forum Updated to NodeBB v4.3 + New Features

QThreadPool , QRunnable and objects that need to be created in main thread

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

    Hi everyone. I'm struggling for a few hours to fix a problem I'm currently facing.
    The problem started with the impossibility to create QWebPage in a separate thread other than main thread(GUI thread): "QWebPage in a different thread":http://developer.qt.nokia.com/forums/viewthread/6425
    Looking further into the problem I realize that QWebPage has some QWidget dependencies so.. I said ok I can't create this in a separate thread.

    My application is using a QThreadPool with 10 threads. For every thread I need to create a QWebPage object and loads some html pages.

    Solutions I can think of:

    1. create all QWebPage objects in main thread and use singal/slot implementation to communicate with the thread.
    2. use moveToThread to move the QWebPage object to the thread after has been created on main thread.

    This are those 2 solutions, however I'm facing some problem/questions:

    For solution #1 : if I'm creating all QWebPage objects in main thread and call them in the main thread what will be the purpose of using threads. wouldn't this be a single thread solution?
    For solution #2 : how can I move the QWebPage to a thread using moveToThread method if I don't know to what thread to move it(I'm using QThreadPool and I don't have(or at least at I don't know) how can I access a certain QThread that will handle a QRunnable currently in queue and waiting pe be executed?

    If you know other solutions, or how to implement those current solution I'll appreciate you're help.

    Thanks.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      You can't move QWebPage to other threads. It uses GUI elements and it must live in the main thread.

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      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