How can I grep the word from QString?
Hi, I'm using qt5.5 on my computer.
For example I have a String like this
QString info; Process::executeProcessSync(QString("sh"),QStringList()<<"-c"<<"| grep \"/dev/sda1 on /run/media/\"",&info);
And i just want to have "some words" inside the info in my other String.
How can i do that?
@victor-wang Do you mean you want to have what grep outputs?
In this case you should first read http://doc.qt.io/qt-5/qprocess.html
Especially http://doc.qt.io/qt-5/qprocess.html#readyReadStandardOutput and http://doc.qt.io/qt-5/qprocess.html#readyReadStandardError
But why do you want to use grep to find something? Starting a new process is a very time consuming and resource intensive operation. It is much faster to do it directly in your app using http://doc.qt.io/qt-5/qstring.html#indexOf or regular expressions.
Thank you! It is exactly what i want!
Can i show the whole file path?
I can only show the device path but not the file where i mounted at.
Is there any way to show the directly path out?
Rootpath method from QStorageInfo returns mount point of a device.