Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Reading a console output into QListWidget

    General and Desktop
    3
    4
    1266
    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.
    • C
      chronix last edited by

      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 Reply Quote 0
      • B
        butterface last edited by

        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 Reply Quote 0
        • C
          chronix last edited by

          [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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • First post
              Last post