How to ensure "%1" like string do have a value ?
-
Hi,
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 ?
-
Use "Qt Regular Expressions":http://developer.qt.nokia.com/doc/qt-4.8/qregexp.html
-
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.