[code]
QWidget *wid  = qobject_cast<QWidget *>(parent());
CSheet *sheet = qobject _cast<CSheet *>(wid->parent());
QScrollArea *scrollArea = qobject _cast<QScrollArea *>(sheet->parent());
CTabWidget *tabWid = qobject _cast<CTabWidget *>(scrollArea->parent());//Here 
it is crashing, QSSERT(d)  failure
CDataPage  *dataPage = qobject _cast<CDataPage *>(tabWid->parent());
MainWindow *mainwin = qobject _cast<MainWindow *>(dataPage->parent());
mainwin->statusBar()->showMessage(tr("A new plot being added!!"),5000);
[/code]

Dear Konstantin

It's not returning anything, it's crashing. When casting to get CTabWidget. For 
the sheet's parent is QScrollBar so I am getting that by scrollArea and 
scrollArea's parent is CTabWidget.....which is getting failure. What could be 
the possible reason, please help. 

Kind regards,


Sujan Dasmahapatra
Project Leader, Aero Group
CE - Aero Group

Tel  +91 80 66470248
Mob  
s...@lmwindpower.com


LM Wind Power Blades
lmwindpower.com

Together we capture the wind to power a cleaner world


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.
-----Original Message-----
From: Konstantin Tokarev [mailto:annu...@yandex.ru] 
Sent: Tuesday, April 24, 2012 6:17 PM
To: Sujan Dasmahapatra
Cc: interest@qt-project.org
Subject: Re: [Interest] type casting 5 levels down no error but not proper


24.04.2012, 16:42, "Sujan Dasmahapatra" <s...@lmwindpower.com>:
> Thanks Diego and Konstantin for your valuable inputs. I am now doing 
> qobject_cast for all of them, please check the code snippet below, now it’s 
> crashing at tabWid step. It’s giving QASSERT failure. The failure is 
> happening in the following file
>
> //qscopedpointer.h at the following line QASSERT(d)
>
>   inline T *operator->() const
>
>     {
>
>         Q_ASSERT(d); //this line it’s crashing.
>
>         return d;
>
>     }

It means that tabWid is QScopedPointer with 0 value. You need to check if 
qobject_cast doesn't return 0 before using pointer.

-- 
Regards,
Konstantin
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to