Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to ensure "%1" like string do have a value ?
c0debreak last edited by
I wanted to let user configure something manually , and user input must have a "%1" and a "%2" inside , and no other "%X" , so that i could use QString::arg() to build the whole string.
But how can i ensure there is and only is two parameters ?
Yasin last edited by
Use "Qt Regular Expressions":http://developer.qt.nokia.com/doc/qt-4.8/qregexp.html
andre last edited by
I think it would be better not to use %1 for this. Qt itself also doesn't (for things like QProgressBar you use %p and the likes). Using numbers is not very readable, using letters a (bit) more so. Also, be careful in your parsing, as the user may want to use a real % sign in the text.