PDA

View Full Version : removing of selected rows



MrShahi
9th June 2008, 06:34
Hello everyone ........
I have a problem that I wana remove selected row from Q3Table but whenever i remove it , there remains one selected row.............
I don't know what mistake I m doing ????
My code is as following ......

void dlgCreateplaylist::pbRemove_clicked()

{



int flag=0;

numberFrame1=0,numberFrame2=0,numberFrame3=0;

pbSelectall2->setText("Select All");

int checked[25],index=0;



/************************************************** ****

*check the row number in table2 is checked or unhecked and remove*********

************************************************** ****/

Q3CheckTableItem *pb1 = new Q3CheckTableItem(Table2, " ");

for(int r=0;r<Table2->numRows();r++)

{

pb1=(Q3CheckTableItem *) Table2->item(r,0);

if(pb1->isChecked())


{



checked[index++]=r;



Table2->removeRow(r);


qDebug()<<"value of Index"<<index;

r=r-1;

flag=1;

flags=0;

}



}


if(flag==0)

{

QMessageBox::information( this, "Createplaylist","Select the Media item to Deleted.");

}

Please if anyone can do something I'll apperciate his reply........Thanx in advance:confused:

jpn
9th June 2008, 09:30
It seems that you are creating a new item (which is never used).

bhs-ittech
9th June 2008, 10:25
As jpn mentions, you add a row to the table whenever pbRemove_clicked() is called.

this happend at line 23 in the shown code
you could avoid this by replacing that line with:


Q3CheckTableItem *pb1 = 0;

MrShahi
10th June 2008, 14:23
Thanx for reply but tht is not solution ...............I just want to remove selected rows nothing else..........
for this I use Q3checkTableItem to only tht perticuler row is Checked or not.........but What mistake I m doing tht there remains one row...............
If you can do something please I really need ur help:(

jpn
10th June 2008, 16:05
Actually it IS the solution.




Q3CheckTableItem *pb1 = new Q3CheckTableItem(Table2, " ");


This will create a NEW item and add it to Table2. According to your problem description this is exactly what you want to avoid.