Results 1 to 3 of 3

Thread: crash on QTreeWidgetItem::data

  1. #1
    Join Date
    Mar 2012
    Location
    china
    Posts
    54
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default crash on QTreeWidgetItem::data

    TreewidgetForCheckbox::TreewidgetForCheckbox(QWidg et *parent) :
    QTreeWidget(parent)
    {
    self_ = false;

    connect(this,SIGNAL(itemChanged(QTreeWidgetItem*,i nt)),
    this,SLOT(OnItemChanged(QTreeWidgetItem*,int)));

    }

    void TreewidgetForCheckbox::OnItemChanged(QTreeWidgetIt em *Aitem, int )
    {

    if(self_ == true)
    return;
    QTreeWidgetItem *parentItem = Aitem->parent();
    int itemstat = Aitem->data(0,Qt::CheckStateRole).toInt();
    if(itemstat ==Qt::PartiallyChecked)
    {}
    }

    why it crash int itemstat = Aitem->data(0,Qt::CheckStateRole).toInt() ???
    }

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: crash on QTreeWidgetItem::data

    Are you sure?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: crash on QTreeWidgetItem::data

    AItem is null or invalid and it is possibly crashing on the line before.
    The item has no column 0, i.e. it was constructed with an empty QStringList.

Similar Threads

  1. Replies: 11
    Last Post: 3rd March 2012, 22:21
  2. how to set custom type data to a QTreeWidgetItem?
    By qlands in forum Qt Programming
    Replies: 2
    Last Post: 4th July 2011, 16:28
  3. Replies: 4
    Last Post: 19th October 2007, 19:47
  4. How to store/get pointer on QTreeWidgetItem data?
    By Teerayoot in forum Qt Programming
    Replies: 2
    Last Post: 28th April 2007, 22:26
  5. crash when delete QTreeWidgetItem*
    By evgenM in forum Qt Programming
    Replies: 9
    Last Post: 9th December 2006, 20:04

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.