QListWidget string increment
Hello, i am trying to populate a QListWidget with the names Somename_1 to Somename_300.. But the problem is the names start with Somename_300 and decrement down to Somename_1 in the QListWidget.. How can i make it insert from Somename_1 and increment to Somename_300.
Code:
for( int i=0 ; i<300; i++ )
{
listWidgetdata
+= QString("SOmename_%1").
arg(i
) + (i
==299 ?
"" : "");
",");
}
for(int j=0; j < listWidgetdata.count();j++)
{
ParamsLW->insertItem(kfast,listWidgetdataat(j)); // kfast =0; at the start of the program
ksast++;
}
ParamsLW is the object name for the QListWidget.
what is going wrong why is the counter starting the names from 300 instead of 1.
thank you
Re: QListWidget string increment
Your code is not working. What about posting the real code? And the best way is a simple loop from 1 to 300 where you add an item at the end.
Also what is item?
Re: QListWidget string increment
hello sir thank you i solved the problem.. it was a very silly mistake kfast was the item number but i incremented ksast i think thats why there was this error. I used the code from some previous post which i found on this forum to auto create incrementing names with numbers. This is what i did now.
Quote:
for( int i=0 ; i<300; i++ )
{
defineparameters.append(QString("Thermo Couple_%1").arg(i));
}
Code:
ParamsLW->insertItem(kfast,listWidgetdataat(j)); // kfast =0;
ksast++; // supposed to be kfast++;
thank you sir problem is solved.