Hi,
I have a QTableWidget with QTextBrowser inherit Widgets on its cells. But when I want to delete a Item I can't reconnect the rest of items.
The code of remove function is the next:
Code:
void Itinerario::on_eliminarToolButton_clicked(){ desconectarWaypoints(); for(int i=0;i<waypoints->rowCount();i++){ WaypointItem *item=static_cast<WaypointItem*>(waypoints->cellWidget(i, TEXTBROWSER_CELLITEM)); if(item->selected()){ item->disconnect(); waypoints->removeRow(i); setWindowModified(true); } return; } } reconectarWaypoints(); }
The code of remove connections is:
Code:
void Itinerario::desconectarWaypoints(){ for(int i=0;i<waypoints->rowCount();i++){ WaypointItem *item=static_cast<WaypointItem*>(waypoints->cellWidget(i, TEXTBROWSER_CELLITEM)); item->disconnect(); } }
And the code of reconnect connections finally is:
Code:
void Itinerario::reconectarWaypoints(){ for(int i=0;i<waypoints->rowCount();i++){ WaypointItem *item=static_cast<WaypointItem*>(waypoints->cellWidget(i, TEXTBROWSER_CELLITEM)); connect(item, SIGNAL(clicked(WaypointItem*, int)), SLOT(waypointClicked(WaypointItem*, int))); connect(item, SIGNAL(doubleClick(WaypointItem*, int)), SLOT(waypointDoubleClicked(WaypointItem*, int))); connect(item, SIGNAL(modifiedChange(bool)), parent(), SLOT(setWindowModified(bool))); } }
I want to reconnect because if I dont do remove-reconnect the connection of removed item appears to be here.
Thanks