Results 1 to 6 of 6

Thread: setText in QTreeWidget Crashes?

  1. #1
    Join Date
    Dec 2006
    Posts
    211
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanks
    27

    Question 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.

    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.
    Last edited by jpn; 1st February 2008 at 09:46. Reason: reformatted to look better

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: setText in QTreeWidget Crashes?

    Can we see the code?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: setText in QTreeWidget Crashes?

    The pointer is invalid? Could you show some code, please?
    J-P Nurmi

  4. #4
    Join Date
    Dec 2006
    Posts
    211
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanks
    27

    Default Re: setText in QTreeWidget Crashes?

    Here it is

    Qt Code:
    1. void MyClass::SetFolderTree(QTreeWidgetItem *treeViewItem,const QString& bFileName, const QString& ID,const QString& parentId)
    2. {
    3. QIcon Folder(":/images/img_Folder.png");
    4. //QSize size(18,18);//Set the size of the Item in treeWidget
    5. QSize folderSize(16,16);
    6. QFont lucidaFont("Lucida Grande", 12);
    7.  
    8. if(!TotalFilesAndFoldersInList.isEmpty())
    9. m_pTotalSizeReadLabel->setText(TotalFilesAndFoldersInList);
    10.  
    11. if(!bFileName.isEmpty())
    12. treeViewItem->setText(0,bFileName);
    13. else
    14. treeViewItem->setText(0,ID);
    15.  
    16. if(!ID.isEmpty())
    17. treeViewItem->setText(1,ID);
    18.  
    19. if(!parentId.isEmpty())
    20. treeViewItem->setText(2,parentId);
    21.  
    22.  
    23. treeViewItem->setFont(0,lucidaFont);
    24.  
    25. treeViewItem->setCheckState (0, Qt::Unchecked );
    26. treeViewItem->setIcon (0, Folder );
    27.  
    28. m_pDiskTree->m_pDiscTreeWidget->setIconSize(folderSize);
    29. //treeViewItem->setSizeHint (0,size );
    30. treeViewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
    31.  
    32. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: setText in QTreeWidget Crashes?

    And where does this "QTreeWidgetItem *treeViewItem" come from?
    J-P Nurmi

  6. #6
    Join Date
    Dec 2006
    Posts
    211
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanks
    27

    Default 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.

    Qt Code:
    1. QTreeWidgetItem *treeViewItem = new QTreeWidgetItem;
    2. treeViewItem->setSizeHint (0,size );
    3.  
    4. emit SetFolderTreeName(treeViewItem,bFileName,qFileId.setNum(MyEntry->dwFileId),QString::number(MyEntry->dwParentId));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. resizing a QTreeWidget
    By drhex in forum Qt Programming
    Replies: 6
    Last Post: 27th October 2006, 22:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.