New blog location
New blog location
class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private slots: void on_pushButton_clicked(); private: Ui::Widget *ui; QStringListModel *strListModel; };
Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { ui->setupUi(this); strListModel = new QStringListModel(this); ui->listView->setModel(strListModel); }
void Widget::on_pushButton_clicked() { QProcess process; QString processName = "ls"; QStringList params; params << "-a" << "/Users/cgavini"; process.start(processName,params); process.waitForFinished(); QString output(process.readAllStandardOutput()); qDebug() << "Output is " << output; auto strList = output.split(QRegExp("[\r\n]"),QString::SkipEmptyParts); strListModel->setStringList(strList); }
Comments
Post a Comment