[Qt-interest] QT string templating

Sean Harmer sean.harmer at maps-technology.com
Tue Feb 8 14:51:59 CET 2011


Hi,

On Tuesday 08 February 2011 19:14:45 Mandeep Sandhu wrote:
> 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.

QList<Employee> employees = ...

foreach ( const Employee& employee, employees )
{
	QString string = QString( "employee=%1, employee_num=%2" )
		.arg( employee.name )
		.arg( employee.number );
	qDebug() << string;
}

Sean




More information about the Qt-interest-old mailing list