Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QProgressDialog and QTConcurrent::run

    General and Desktop
    1
    2
    949
    Loading More Posts
    • 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.
    • D
      DimitriJunker last edited by

      Hi,

      Let say I want to download 100 pictures in multiple threads, but not 100. So I use something like:

      @void MainW::makePmap()
      {
      ...
      for(int threadNr=0;threadNr<data->m_maxThreads;threadNr++)
      QtConcurrent::run(loadPMapInThread,data);
      ...
      }
      @

      the function called lookes like:
      @
      void loadPMapInThread( SDLM_DATA * data )
      {
      ...
      }
      @

      Now every time one of the threads finished one picture (map) it should send a signal to the main thread, so that this can update a QTProgressDialog. As far as I understand the signal slot system I would use emit inside of loadPMapInThread to send a signal and use a slot in the MainW to receive it and update the ProgressDialog. But what I don't understand is the function connect:
      bool QObject::connect ( const QObject * sender, const char * signal, const QObject * receiver, const char * method, Qt::ConnectionType type = Qt::AutoConnection ) [static]
      The receiver is MainW and method the receiving slot, signal is what I use with emit, but what do I set sender to? loadPMapInThread is not member of a class derrived from QObject.
      And the same problem will ocure if I want to connect a signal to cancel the download when the cancel-Button of dthe QProgressDialog is pressed.
      Dimitri

      1 Reply Last reply Reply Quote 0
      • D
        DimitriJunker last edited by

        thanks, that looks fine. I finished programming it and did some tests.
        Dimitri

        1 Reply Last reply Reply Quote 0
        • First post
          Last post