View Full Version : QTableWidget Bug : can't remove row !

14th May 2009, 19:40
hello everybody
i want to remove the selected row in my QTableWidget , i am using :


pieces is the QTableWidget , i have no errors in compilation.
but when i select a row and click on a button to run the action , my application shutdown :(
i tried also removeRow(pieces->currentRow()); and i have the same problem :confused:

the problem is in removeRow() because i tried hideRow() and it was working perfectly :(

any idea please :eek:

15th May 2009, 09:05
can you show some more code

15th May 2009, 10:33
I'd guess you are doing it from a slot connected to a signal that emits a QTableWidgetItem as its argument. Is that correct?

15th May 2009, 14:28
thnaks for your responses

this is my code :

here , a QPushButton to run the action :

void AcheterMed::on_suppMed_clicked()

pieces is my QTableWidget , i add items in with this code :

void AcheterMed::on_valider_clicked()
QTableWidgetItem *item1 = new QTableWidgetItem;
QTableWidgetItem *item2 = new QTableWidgetItem;
int j = pieces->rowCount();
for(int i=0;i<nbrePieces->text().toInt();i++)
pieces->insertRow(j + i);
pieces->setItem(j + i,0,item1);
pieces->setItem(j + i,1,item2);

and i have no others slots !
i still have the same problem :(

n.b : i want to remove the row selected from pieces , pieces is set to singleselections + selectrows .

this is all !

thanks again :)

i had also the same problem with clearContents() of my QTableWidget , but i use setRowCount(0) , and it's working :)

16th May 2009, 12:07
hello again !
whene i debug i have the famous " Segmentation fault "
my window is made with Designer .

16th May 2009, 22:53
Use the debugger to find out where the crash occurs by printing the backtrace.

17th May 2009, 03:15
thanks again ;

but i changed my plan , i deleted all the QTablewidgets , no i am using table views with models (QStandardItemModel + QTableView = QTableWidget ) ; it's better !

i have no craches , no problems
i confirm that the problem was in the QTableWidget (many not only one )
sometimes it works , and sometimes all functions cause errors (removeRow , clearContents , setRowCount , setItem , item ...)
and i am not the one , if you look at google you will find a lot of similar problems with this widget !!

so models are better + fast

thanks :)

17th May 2009, 12:14
another one bites the dust :) no doubt it requires a bit extra effort, but using proper Model View classes is always the best..and gives you more inside info..soon you'll be pulling towards delegates..and yes, good decision ;)