remove string from a qstringlist
-
wrote on 13 Apr 2018, 11:10 last edited by saber
i put my linux partition in a qstringlist and add this qstringkist in a listview.but the list also have some items that are not partition .so how can i remove them from qstringlist.
this non-partition usually has only 3 letter in name.
last one is dvd drive.it also be removed from the qstringlist. -
i put my linux partition in a qstringlist and add this qstringkist in a listview.but the list also have some items that are not partition .so how can i remove them from qstringlist.
this non-partition usually has only 3 letter in name.
last one is dvd drive.it also be removed from the qstringlist.wrote on 13 Apr 2018, 11:25 last edited byI think you should focus on not adding them in the first place
@saber said in remove string from a qstringlist:
i put my linux partition in a qstringlist
How?
-
I think you should focus on not adding them in the first place
@saber said in remove string from a qstringlist:
i put my linux partition in a qstringlist
How?
-
@VRonin i can't do that.
because the cpp file that i use to collect partition is not licensed gpl.
so i need to do that steps above.wrote on 13 Apr 2018, 12:48 last edited by VRonin@saber said in remove string from a qstringlist:
is not licensed gpl.
I thought Qt was already capable of doing that. I don't have a unix system available at the moment but this should work:
QStringList result; const auto allMounted = QStorageInfo::mountedVolumes(); result.reserve(allMounted.size()); for(auto& singleMounted : allMounted) result << singleMounted.displayName();
If you really want to go the remove way, however, you just need to use
stringList = stringList.filter(QRegularExpression(QStringLiteral("[a-z]{3}")));
-
@saber said in remove string from a qstringlist:
is not licensed gpl.
I thought Qt was already capable of doing that. I don't have a unix system available at the moment but this should work:
QStringList result; const auto allMounted = QStorageInfo::mountedVolumes(); result.reserve(allMounted.size()); for(auto& singleMounted : allMounted) result << singleMounted.displayName();
If you really want to go the remove way, however, you just need to use
stringList = stringList.filter(QRegularExpression(QStringLiteral("[a-z]{3}")));
-
@saber said in remove string from a qstringlist:
is not licensed gpl.
I thought Qt was already capable of doing that. I don't have a unix system available at the moment but this should work:
QStringList result; const auto allMounted = QStorageInfo::mountedVolumes(); result.reserve(allMounted.size()); for(auto& singleMounted : allMounted) result << singleMounted.displayName();
If you really want to go the remove way, however, you just need to use
stringList = stringList.filter(QRegularExpression(QStringLiteral("[a-z]{3}")));
wrote on 13 Apr 2018, 13:42 last edited by -
@saber Ok, so
blockDevices()
is your own function which queries the drives via DBus.So while you could filter them out later, better would be to query actual partitions via DBus. Maybe someone with more DBus knowledge can tell if that is possible, and how.
-
@saber said in remove string from a qstringlist:
is not licensed gpl.
I thought Qt was already capable of doing that. I don't have a unix system available at the moment but this should work:
QStringList result; const auto allMounted = QStorageInfo::mountedVolumes(); result.reserve(allMounted.size()); for(auto& singleMounted : allMounted) result << singleMounted.displayName();
If you really want to go the remove way, however, you just need to use
stringList = stringList.filter(QRegularExpression(QStringLiteral("[a-z]{3}")));
-
@saber said in remove string from a qstringlist:
can i get the mount path of mounted partition ??
One possibility would be to execute "mount" command using QProcess and parse its output.
-
@saber said in remove string from a qstringlist:
can i get the mount path of mounted partition ??
One possibility would be to execute "mount" command using QProcess and parse its output.
wrote on 17 Apr 2018, 03:05 last edited by saber@jsulm i did this
QStringList result; const auto allMounted = QStorageInfo::mountedVolumes(); result.reserve(allMounted.size()); for(auto& singleMounted : allMounted) result << singleMounted.displayName(); // const auto allMounted = QStorageInfo::mountedVolumes(); for(int i=0; i<result.count(); ++i ){ QString l; l = result.at(i); QStorageInfo(l).rootPath(); qDebug()<<QStorageInfo(l).rootPath(); }
output
"/run" "/" "/tmp" "/run/user/1000" "" "" ("/run", "/", "/tmp", "/run/user/1000", "Storage", "Fast")
@aha_1980 @VRonin guys , i want also last two storage mounted path and remove "/run" "/tmp" , "/run/user/1000" .but how??
1/10