Consider this code
{
public:
SomeClass();
...
private:
};
{
}
{
if(_listWgt){
_listWgt->clear();
}
// Code to repopulate _listWgt with new list of items base on 'itemText'
// follows.
}
class SomeClass : public QWidget
{
public:
SomeClass();
...
private:
QListWidget* _listWgt;
};
SomeClass::SomeClass(QWidget* parent) : QWidget(parent)
{
_listWgt = new QListWidget(this);
connect(_listWgt, SIGNAL(itemDoubleClicked(QListWidgetItem*), this, SLOT(onItemDoubleClicked(QListWidgetItem*));
}
void SomeClass::onItemDoubleClicked(QListWidgetItem* item)
{
QString itemText = item->text();
if(_listWgt){
_listWgt->clear();
}
// Code to repopulate _listWgt with new list of items base on 'itemText'
// follows.
}
To copy to clipboard, switch view to plain text mode
My code is crashing in Qt as some timer event occurs on _listWgt that perhaps has information of _listWgt before it entered onItemDoubleClicked() slot, but after this slot is done, _listWgt doesn't reflect that state.
I'm suspecting clear() as technically, it will try to delete the item on which the doubleClicked signal happened.
Can anyone agree or confirm my suspicion?
Thanks.
Bookmarks