Hi,
I fill a QTableWidget in scope:
{
[...]
wdg_check *wdgl_check = new wdg_check();
ui.languages->setCellWidget( currentRow, 2, wdgl_check );
QObject::connect( ui.
languages->cellWidget
(currentRow,
2),
SIGNAL(newSelection
()),
this,
SLOT(page1_selection_change
()) );
[...]
ui.languages->setItem( currentRow, 6, newItemC);
}
// ui.languages->sortItems( 6, Qt::AscendingOrder );
{
[...]
wdg_check *wdgl_check = new wdg_check();
ui.languages->setCellWidget( currentRow, 2, wdgl_check );
QObject::connect( ui.languages->cellWidget(currentRow,2), SIGNAL(newSelection()), this, SLOT(page1_selection_change()) );
[...]
QTableWidgetItem *newItemC = new QTableWidgetItem( i.value()["ol"]+"-"+i.value()["fl"] );
ui.languages->setItem( currentRow, 6, newItemC);
}
// ui.languages->sortItems( 6, Qt::AscendingOrder );
To copy to clipboard, switch view to plain text mode
where ui.languages is a QTableWidget and i.value() a QMap<QString, QString>. wdg_check is a simple Widget with a QCheckbox, which emit the SIGNAL newSelection(), when the state of QCheckbox is changed. And wdg_check provides the function getStatus(), which returns wether the QCheckBox is checked or not (bool).
so I have defined the connection-slot as:
void dgl_newBin::page1_selection_change()
{
for (int i = 0; i < ui.languages->rowCount(); ++i)
{
bool state = static_cast<wdg_check*>(ui.languages->cellWidget(i,2))->getStatus();
}
// (I have all stuf deleted, which doesn't cause the Problem)
}
void dgl_newBin::page1_selection_change()
{
for (int i = 0; i < ui.languages->rowCount(); ++i)
{
bool state = static_cast<wdg_check*>(ui.languages->cellWidget(i,2))->getStatus();
}
// (I have all stuf deleted, which doesn't cause the Problem)
}
To copy to clipboard, switch view to plain text mode
Ok, if I run the application with that code, all works, but if I uncomment the line "ui.languages->sortItems( 6, Qt::AscendingOrder );" I get an segmentation fault at the line "bool state = static_cast<wdg_check*>(ui.languages->cellWidget(i,2))->getStatus();".
Why? Isn't ui.languages->cellWidget(i,2) valid after sorting?
Thanks,
Lykurg
Bookmarks