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. How to launch multiple processes but not create seperate slots for each process instance
Forum Updated to NodeBB v4.3 + New Features

How to launch multiple processes but not create seperate slots for each process instance

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 802 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.
  • K Offline
    K Offline
    ki John
    wrote on last edited by
    #1

    I want to run a few processes at the same time and I want to add each new instance to a list of processes but I want each process to update it's own progress bar. I have a list of progress bars also, and it has the same index numbers as the corresponding process instance.

    However I am not sure how to pass that index number to the slots.

    @ void MainWindow::runAllProcesses()
    {
    .....
    process = new QProcess(this);
    connect( process, SIGNAL(started()), this, SLOT(processStarted()));
    connect( process, SIGNAL(readyRead()), this, SLOT(processRead()));
    connect( timer, SIGNAL( timeout()), this, SLOT(timesup()));
    @

    Ideally, if I could have a parameter to processStarted( instanceNumber) would be best but readyRead() and processRead() don't take any parameters.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      You can use "QSignalMapper":http://qt-project.org/doc/qt-5/qsignalmapper.html#details to pass parameters through the signals that do not support parameters.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thEClaw
        wrote on last edited by
        #3

        If you are using Qt5, you could probably use the new signal/slot-syntax in conjunction with a lambda expression_ _ (needs C++11).
        Something similar to this:
        @process = new QProcess(this);
        connect(process, &QProcess::started, this, this
        {
        processStarted();//you may pass a parameter or just do necessary things right here
        });@

        There is a very helpful "article":http://qt-project.org/wiki/New_Signal_Slot_Syntax on these things.

        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