QProcess return string > qlistview?

  • The code below (using QProcess) does a find and returns the result in a qstring "command".

    QProcess mprocess;
    cstring = "adb shell su -c find /storage/usb/ -name update.zip" ;

    If the find has results QProcess seems to place them into the qstring with an eol after each item:


    How can I break up this qstring and add each subitem to a qlistview? As expected the code below doesn't work. The listview looks like it has four items, but of course there's just one.

    QListWidgetItem *newItem = new QListWidgetItem;
    ui->listWidget->insertItem(0, newItem);

    Edit: I tried:

    QStringList list1 = command.split(endl);

    error: no matching member function for call to 'split'
    QStringList list1 = command.split(endl);

    Which I don't get, it's a copy/paste from the docs:



  • Lifetime Qt Champion


    You can use "QString::split":http://qt-project.org/doc/qt-5/qstring.html#split to create a QStringList, create a QStringListModel for a QListView. Other wise use a loop to create all the items you need for a QListWidget.

    Hope it helps

Log in to reply

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