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. QProgressDialog and QTConcurrent::run

QProgressDialog and QTConcurrent::run

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

    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
    0
    • D Offline
      D Offline
      DimitriJunker
      wrote on last edited by
      #2

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

      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