[Qt-interest] QT string templating
Mandeep Sandhu
mandeepsandhu.chd at gmail.com
Wed Feb 9 05:47:41 CET 2011
> Sounds to me like QString::replace() is exactly what you want, at least nothing indicates
> that you need anything more elaborate.
Yup, looks like this will do the job.
The templated string that I receive is from an external source...I
could ask that source to provide me the string pre-populated with
%<num> args. But replacing %1 with emp name, %2 with emp # etc. does
not look very intuitive. Rather I would like to do name based
substitution. Eg: how its done in python :
http://docs.python.org/library/string.html#template-strings
"$who likes $what" looks better than "%1 likes %2" ! :)
For this replace() looks good enough.
Thanks you all for your inputs.
Regards,
-mandeep
>
> On Feb 8, 2011, at 15:44 , Mandeep Sandhu wrote:
>
>> Hi All,
>>
>> Is there any support for string templating in QT?
>>
>> I came upon Grantlee (http://www.gitorious.org/grantlee/pages/Home),
>> but that seems to have a lot more features than my simple requirement.
>>
>> For eg: if given a string "employee=<EMP_NAME>,
>> employee_num=<EMP_NUM>", I need a a way to specify that <EMP_NAME> and
>> <EMP_NUM> be replaced by certain values.
>>
>> Is there a builtin way to replace the keywords in this template? (I
>> could use QRegExp and QString, but that would be a workaround).
>>
>> Thanks,
>> -mandeep
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
> --
> Jan Ekholm
> jan.ekholm at smultron.net
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list