Reading a console output into QListWidget



  • Hey i've banging my head over this over a week now!
    i need to run a script through Qt GUI app!
    this scripts simply lists all the groups in the system( ie. runs /bin/./groups)
    now i want this output in the QListWidget!
    i run the script using QProcess!
    bt im not able to get the output of the script to the GUI
    i know i have to use readAllStandardOutput(); bt how???????
    pls help me and consider me a noob! :(



  • That's how I always do it:

    @
    QProcess *testProcessServer = new QProcess();
    QStringList argumentsServer;
    testProcessServer->setProcessChannelMode(QProcess::MergedChannels);
    testProcessServer->start(programServer, argumentsServer);
    int status = 0;
    if (!testProcessServer->waitForStarted())
    {
    // do something here
    }
    textbox->append(QString(testProcessServer->readAll()));
    @



  • [quote author="butterface" date="1402663078"]That's how I always do it:

    @
    QProcess *testProcessServer = new QProcess();
    QStringList argumentsServer;
    testProcessServer->setProcessChannelMode(QProcess::MergedChannels);
    testProcessServer->start(programServer, argumentsServer);
    int status = 0;
    if (!testProcessServer->waitForStarted())
    {
    // do something here
    }
    textbox->append(QString(testProcessServer->readAll()));
    @[/quote]
    Thanks for the reply! well i solves the issue!
    i said i have to display into QListWidget!
    can we convert QByteArray to QStringList?


  • Lifetime Qt Champion

    Hi,

    Like in the example, build the string from the QByteArray and then just split the string on the "\n" char


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.