pcoliver
5th January 2012, 10:38
Hello all,
As always I turn to the experts. I have little time programming in Qt4 and I have yet a lot of documentation to review progress on my projects, but hey I guess that happened to us all.
I have a problem not solve it.
I have a list of this type 01000000000,02000000000,03000000000 defined with QStringList.
The problem I have is that it removes the last element of the list 03000000000. If I've managed to eliminate the first and second but not the ulitmo. I require your knowledge to see if you can give me some solution, pq stand for two days with this nonsense, I know I'm clumsy.
I leave part of the code to see if you can lend a hand to me.
What I do is first find the total number of items in the list.
Locate the item that interests me and that begins to erase 02.
Delete the item.
I tried to delete the item RemoveAt (), with removeLast, but if the item does not get ulitmo delete it.
I leave the code and thank you very much for your help.
***************************************
#define REGPATH_XXXXXXXX "HKEY_LOCAL_MACHINE\\SOFTWARE\\XXXXX"
int TotalListaN;
QStringList listOODelN;
int PosicionOODelN=0;
int IndiceOODelN=0;
QString MostrarMensaje ="";
QString sAplicacionesOODelN = settings::getRegAppInstaladas();
int TotalElementosListaN = 0;
int ntN=0;
int IndiceOON2=0;
int PosicionOON2=0;
QSettings settings(REGPATH_XXXXXXXX,QSettings::NativeFormat) ;
// listOODelN.sort();
if(sAplicacionesOODelN.size() > 0)
{
listOODelN = sAplicacionesOODelN.split(",");
}
QStringList::const_iterator constIteratorOODelN;
//Vamos a averiguar donde esta la cadena 02000 en la lista
for (constIteratorOODelN = listOODelN.constBegin(); constIteratorOODelN != listOODelN.constEnd(); ++constIteratorOODelN){
TotalElementosListaN=ntN;
}
int vListCount;
vListCount = listOODelN.count();
int i;
bool encontrado(false);
int PosicionLista=-1;
QMessageBox::information ( 0,"TOTAL ELEMENTOS LISTA", "El numero total de elementos en la lista es: "+QString::number(vListCount));
for (i=0; i
{
QMessageBox::information(0,"Contenido Lista i ", listOODelN[i],"Ok",0,0,0);
QMessageBox::information ( 0,"Posicion Elemento", "La posicion en la lista es: "+QString::number(i));
if (listOODelN[i].startsWith("02")){
PosicionOON2=i;
encontrado=true;
QMessageBox::information(0,"Encontrado Valor en Posicion :", QString::number(i));
PosicionLista=i;
}
}
int vListCountReal=vListCount-1;
foreach (QString str, listOODelN) {
//if (str.startsWith("02")){QMessageBox::information(0, "String Parser", listOODelN[i],"Ok",0,0,0);
//QMessageBox::information(0,"VALORES A MOSTRAR:","Valor encontrado",QString::bool(encontrado));
QMessageBox::information(0,"Total Valores Lista vlistcount :", QString::number(vListCount));
QMessageBox::information(0,"Posicion en la lista PosicionLista:", QString::number(PosicionLista));
if (str.startsWith("02") && encontrado==true){
if (PosicionLista=vListCountReal)
{
QMessageBox::information(0,"VALOR ENCONTRADO ","ENCONTRADO OK");
QMessageBox::information(0,"valor a borrar ","Posicion Lista:", QString::number(PosicionLista), "vListCountReal:",QString::number(vListCount-1));
listOODelN.append( );
listOODelN.removeAt(PosicionLista);
}else
{
PosicionOODelN=PosicionLista;
QMessageBox::information(0,"ANTES DE BORRAR . POSICION EN LA LISTA",QString::number(PosicionOODelN));
listOODelN.removeAt(PosicionOODelN);
//QMessageBox::information(0,"DEBUG AGENTE",listOODel.at(PosicionOO));
sAplicacionesOODelN = listOODelN.join(",");
// QMessageBox::information(0,"BORRAMOS CONTENIDO LISTA",sAplicacionesOODel1);
}
}
else {
settings.setValue("Apl", sAplicacionesOODelN);
}
IndiceOODelN++;
}
}//Fin Procedimiento BorrarContenidoListaOO()
****************************************
As always I turn to the experts. I have little time programming in Qt4 and I have yet a lot of documentation to review progress on my projects, but hey I guess that happened to us all.
I have a problem not solve it.
I have a list of this type 01000000000,02000000000,03000000000 defined with QStringList.
The problem I have is that it removes the last element of the list 03000000000. If I've managed to eliminate the first and second but not the ulitmo. I require your knowledge to see if you can give me some solution, pq stand for two days with this nonsense, I know I'm clumsy.
I leave part of the code to see if you can lend a hand to me.
What I do is first find the total number of items in the list.
Locate the item that interests me and that begins to erase 02.
Delete the item.
I tried to delete the item RemoveAt (), with removeLast, but if the item does not get ulitmo delete it.
I leave the code and thank you very much for your help.
***************************************
#define REGPATH_XXXXXXXX "HKEY_LOCAL_MACHINE\\SOFTWARE\\XXXXX"
int TotalListaN;
QStringList listOODelN;
int PosicionOODelN=0;
int IndiceOODelN=0;
QString MostrarMensaje ="";
QString sAplicacionesOODelN = settings::getRegAppInstaladas();
int TotalElementosListaN = 0;
int ntN=0;
int IndiceOON2=0;
int PosicionOON2=0;
QSettings settings(REGPATH_XXXXXXXX,QSettings::NativeFormat) ;
// listOODelN.sort();
if(sAplicacionesOODelN.size() > 0)
{
listOODelN = sAplicacionesOODelN.split(",");
}
QStringList::const_iterator constIteratorOODelN;
//Vamos a averiguar donde esta la cadena 02000 en la lista
for (constIteratorOODelN = listOODelN.constBegin(); constIteratorOODelN != listOODelN.constEnd(); ++constIteratorOODelN){
TotalElementosListaN=ntN;
}
int vListCount;
vListCount = listOODelN.count();
int i;
bool encontrado(false);
int PosicionLista=-1;
QMessageBox::information ( 0,"TOTAL ELEMENTOS LISTA", "El numero total de elementos en la lista es: "+QString::number(vListCount));
for (i=0; i
{
QMessageBox::information(0,"Contenido Lista i ", listOODelN[i],"Ok",0,0,0);
QMessageBox::information ( 0,"Posicion Elemento", "La posicion en la lista es: "+QString::number(i));
if (listOODelN[i].startsWith("02")){
PosicionOON2=i;
encontrado=true;
QMessageBox::information(0,"Encontrado Valor en Posicion :", QString::number(i));
PosicionLista=i;
}
}
int vListCountReal=vListCount-1;
foreach (QString str, listOODelN) {
//if (str.startsWith("02")){QMessageBox::information(0, "String Parser", listOODelN[i],"Ok",0,0,0);
//QMessageBox::information(0,"VALORES A MOSTRAR:","Valor encontrado",QString::bool(encontrado));
QMessageBox::information(0,"Total Valores Lista vlistcount :", QString::number(vListCount));
QMessageBox::information(0,"Posicion en la lista PosicionLista:", QString::number(PosicionLista));
if (str.startsWith("02") && encontrado==true){
if (PosicionLista=vListCountReal)
{
QMessageBox::information(0,"VALOR ENCONTRADO ","ENCONTRADO OK");
QMessageBox::information(0,"valor a borrar ","Posicion Lista:", QString::number(PosicionLista), "vListCountReal:",QString::number(vListCount-1));
listOODelN.append( );
listOODelN.removeAt(PosicionLista);
}else
{
PosicionOODelN=PosicionLista;
QMessageBox::information(0,"ANTES DE BORRAR . POSICION EN LA LISTA",QString::number(PosicionOODelN));
listOODelN.removeAt(PosicionOODelN);
//QMessageBox::information(0,"DEBUG AGENTE",listOODel.at(PosicionOO));
sAplicacionesOODelN = listOODelN.join(",");
// QMessageBox::information(0,"BORRAMOS CONTENIDO LISTA",sAplicacionesOODel1);
}
}
else {
settings.setValue("Apl", sAplicacionesOODelN);
}
IndiceOODelN++;
}
}//Fin Procedimiento BorrarContenidoListaOO()
****************************************