[Qt-interest] Not able to delete a QGraphicsItem

Alexis Ménard alexis.menard at trolltech.com
Wed Apr 22 15:17:39 CEST 2009


On Wednesday 22 April 2009 14:45:32 Sujan Dasmahapatra wrote:
> Dear Friends
>
> I have a QGraphicsItem what I am hiding and showing and after that trying
> to check whether it selected or not...It's crashing  I think its  a Qt
> bug.Please help what  have I done wrong else ?
>

I would say it is not a Qt bug...

gdb and breakpoints or qdebug may help you.

test the value of currentRow(), then geoMetry[currentRow()]

and if one of them is 0 or pointer garbage you know why it crash. Then you 
have to fix your code, probably in deletePart some stuff is already deleted.

>
>
> See the code below. 1st I am calling  hidePart() and then calling
> showPart() after that Calling deletePart() it's  crashing at the first line
>
> --------à        geoMetry[currentRow()]->isSelected()
>
> Program received signal SIGSEGV, Segmentation fault to evaluate the value
> of    geoMetry[currentRow()]->isSelected()
>
> void TableWidget::showPart()
>
> {
>
>         if(item[currentRow()]->isSelected()==true)
>
>                 {
>
>                 geoMetry[currentRow()]->show();
>
>                 geoMetry[currentRow()]->setSelected(true);
>
>                 geoMetry[currentRow()]->setVisible(true);
>
>                 }
>
>         else
>
>                 return;
>
> }
>
>
>
> void TableWidget::hidePart()
>
> {
>
>         if(geoMetry[currentRow()]->isSelected() == true)
>
>                 geoMetry[currentRow()]->hide();
>
>         else
>
>                 return;
>
>
>
> }
>
>
>
> void TableWidget::deletePart()
>
> {
>
>         if(geoMetry[currentRow()]->isVisible() == true &&
> geoMetry[currentRow()]->isSelected() == true)
>
>         {
>
>                 delete geoMetry[currentRow()];
>
>                 geoMetry.removeOne(geoMetry[currentRow()]);
>
>                 item.removeOne(item[currentRow()]);
>
>                 removeRow(currentRow());
>
>                 countTableWidget--;
>
>                 if(countTableWidget==0)
>
>                 {
>
>                         geoMetry.clear();
>
>                         item.clear();
>
>                         return;
>
>                 }
>
>
>
>         }
>
>         else
>
>         return;
>
>
>
> }
>
>
>
>
>
> Kind regards,
> LM Glasfiber R&D (India) Pvt. Ltd.
>
> Sujan Dasmahapatra
> Senior Engineer - CFD
>
> Telephone: +91 80 66470248
> Mobile:9900839788
> E-mail: sdh at lmglasfiber.com <mailto:sdh at lmglasfiber.com>
>
>
>
>
>
>
>
>
>
> --------------------------------------------------------------
>
> This e-mail and any attachments are confidential. If you are not the named
> or intended recipient, please notify the sender immediately and do not
> disclose the contents to any other person, use it for any purpose or store
> or copy the information in any medium. Any unauthorized disclosure, use or
> storage is prohibited and might be unlawful.

-- 

Alexis Ménard
Software Engineer, Widgets Team 1
Qt Software, Nokia Norge AS, Sandakerveien 116, 0484 Oslo, Norway
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090422/f204e63f/attachment.html 


More information about the Qt-interest-old mailing list