I wanted to copy a QStringList to another QStringList but only taking the odd positions.
Qt Code:
. . .To copy to clipboard, switch view to plain text mode
Someone has idea?
Thanks.
I wanted to copy a QStringList to another QStringList but only taking the odd positions.
Qt Code:
. . .To copy to clipboard, switch view to plain text mode
Someone has idea?
Thanks.
Last edited by jpn; 16th May 2008 at 20:33. Reason: missing [code] tags
Hi,
Use something similar to this:
Qt Code:
int i=0; int j=1; while (i<im.count()) { pa[j] = im[i]; i++; j +=2; }To copy to clipboard, switch view to plain text mode
Not tested
Òscar Llarch i Galán
tried in many ways, but always occurs Segmentation fault.
Qt Code:
while (i < pa.count()) { im[i] = pa[j]; i++; j +=2; }To copy to clipboard, switch view to plain text mode
there is no way in Qt?
Last edited by jaca; 16th May 2008 at 21:56.
You have to resize the list or use append() to insert items and the indexes of the list have to be a sequence. If you want only odd index numbers, use QMap.
Qt Code:
int index = 1; QStringList inlist; QMap<int, QString> out; out[index] = str; index+=2; }To copy to clipboard, switch view to plain text mode
tried this code:
Qt Code:
QMap<int, QString>::const_iterator i = out.constBegin(); while (i != out.constEnd()) { cout << i.key() << ": " << i.value() << endl; ++i; }To copy to clipboard, switch view to plain text mode
Only I could not show values. As I see the values of QMap?
Thanks.
Last edited by jaca; 16th May 2008 at 21:55.
Do you have console support enabled? I suggest using QMessageBox instead of cout to be sure.
Bookmarks