[Qt-interest] QSqlQuery: Binding QStringLists

Jeremy Lainé jeremy.laine at bolloretelecom.eu
Tue Sep 20 12:17:25 CEST 2011


I use something along the following lines for the QDjango ORM [1]:

QStringList placeholders;
for (int i = 0; i < stringList.size(); ++i)
     placeholders << "?";

query.prepare("delete from TableName where value not in (" + placeholders.join(", ") + ")");
for (int i = 0; i < stringList.size(); ++i)
     query.addBindValue(stringList[i]);

[1] http://opensource.bolloretelecom.eu/projects/qdjango/

-- 
Jeremy LAINE
Bolloré telecom | 11bis, rue Scribe | F-75009 Paris




More information about the Qt-interest-old mailing list