setText in QTreeWidget Crashes?
Hi All,
I am working on Qt 4.2.2 on my MAC.
I have set the text of the QTreeWidgetItem by using setText(QString).
I am getting the following crash report.
Quote:
PID: 163
Thread: 0
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000026
Thread 0 Crashed:
0 MyApp 0x00153b18 QTreeModel::index(QTreeWidgetItem const*, int) const + 76
1 MyApp 0x00154524 QTreeModel::parent(QModelIndex const&) const + 112
2 MyApp 0x0046d310 QModelIndex::parent() const + 60
3 MyApp 0x00161604 QTreeViewPrivate::viewIndex(QModelIndex const&) const + 84
4 MyApp 0x001641b0 QTreeView::dataChanged(QModelIndex const&, QModelIndex const&) + 124
5 MyApp 0x00166cc4 QTreeView::qt_metacall(QMetaObject::Call, int, void**) + 292
6 MyApp 0x0015a59c QTreeWidget::qt_metacall(QMetaObject::Call, int, void**) + 40
7 StellarPhoenix 0x0006a3d8 QMetaObject::activate(QObject*, int, int, void**) + 1240
8 MyApp 0x0029eeac QAbstractItemModel::dataChanged(QModelIndex const&, QModelIndex const&) + 64
9 MyApp 0x00154808 QTreeModel::emitDataChanged(QTreeWidgetItem*, int) + 396
10 MyApp 0x00157b4c QTreeWidgetItem::setData(int, int, QVariant const&) + 1096
11 MyApp 0x00443d80 QTreeWidgetItem::setText(int, QString const&) + 72
If any body knows why it is crashing then plz help me.
Thanks.
Re: setText in QTreeWidget Crashes?
Re: setText in QTreeWidget Crashes?
The pointer is invalid? Could you show some code, please?
Re: setText in QTreeWidget Crashes?
Here it is
Code:
void MyClass
::SetFolderTree(QTreeWidgetItem *treeViewItem,
const QString
& bFileName,
const QString
& ID,
const QString
& parentId
) {
QIcon Folder
(":/images/img_Folder.png");
//QSize size(18,18);//Set the size of the Item in treeWidget
QFont lucidaFont
("Lucida Grande",
12);
if(!TotalFilesAndFoldersInList.isEmpty())
m_pTotalSizeReadLabel->setText(TotalFilesAndFoldersInList);
if(!bFileName.isEmpty())
treeViewItem->setText(0,bFileName);
else
treeViewItem->setText(0,ID);
if(!ID.isEmpty())
treeViewItem->setText(1,ID);
if(!parentId.isEmpty())
treeViewItem->setText(2,parentId);
treeViewItem->setFont(0,lucidaFont);
treeViewItem->setCheckState (0, Qt::Unchecked );
treeViewItem->setIcon (0, Folder );
m_pDiskTree->m_pDiscTreeWidget->setIconSize(folderSize);
//treeViewItem->setSizeHint (0,size );
treeViewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
}
Re: setText in QTreeWidget Crashes?
And where does this "QTreeWidgetItem *treeViewItem" come from?
Re: setText in QTreeWidget Crashes?
I am declaring it in the calling function and since I need its value in this function so I emit the signal SetFolderTreeName for which the code I have sent you eariler is Slot.
Code:
treeViewItem->setSizeHint (0,size );
emit SetFolderTreeName
(treeViewItem,bFileName,qFileId.
setNum(MyEntry
->dwFileId
),
QString::number(MyEntry
->dwParentId
));