iunknwn
30th September 2015, 17:21
Consider this code
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.
}
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.
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.
}
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.