QStrings and C ++ lines solve different problems - the main difference is that QStrings explicitly processes locales / encodings, while std :: strings does not.
therefore, use QStrings for all data entered by users and all lines that will be displayed to your users, or you risk losing information in conversions and / or making it difficult to internationalize your application in the future.
For something where I just need the equivalent of char *, for example. storing data read from a database where locales / encodings are not applicable, I use std :: strings, since it is much easier to use with libraries other than Qt, and your data does not fall into any encoding transformations. However, you must explicitly add them to a qt type system in order to be able to use them in the signal / slot arguments, which is easy as soon as you know how to do this.
But in the end, this solution is just to make your codebase more accessible for beginners, it might be better to just use QString everywhere or maybe just std :: string everywhere if you use QtCore in a non-gui application.
je4d
source share