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. Reading a console output into QListWidget
QtWS25 Last Chance

Reading a console output into QListWidget

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.5k 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.
  • C Offline
    C Offline
    chronix
    wrote on last edited by
    #1

    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! :(

    1 Reply Last reply
    0
    • B Offline
      B Offline
      butterface
      wrote on last edited by
      #2

      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()));
      @

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chronix
        wrote on last edited by
        #3

        [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?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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