I have my mainwindow which is QMainWindow the parent of all my other classes. I am type casting upwards from 5 levels down using reinterpret_cast, to access the mainwindow to display message using statusBar(), but when type casting it's not giving error but when accessing mainwindow->statusBar() it's crashing.

please check the code snippet below:

Qt Code:
  1. QWidget *wid = reinterpret_cast<QWidget *>(parent());
  2. CSheet *sheet = reinterpret_cast<CSheet *>(wid->parent());
  3. QScrollBar *scrollBar = reinterpret_cast<QScrollBar *>(sheet->parent());
  4. CTabWidget *tabWid = reinterpret_cast<CTabWidget *>(scrollBar->parent());
  5. CDataPage *dataPage = reinterpret_cast<CDataPage *>(tabWid->parent());
  6. MainWindow *mainwin = reinterpret_cast<MainWindow *>(dataPage->parent());
  7. mainwin->statusBar()->showMessage(tr("A new plot being added!!"),5000); //[I][SIZE=7]Here it is crashing[/SIZE][/I]
To copy to clipboard, switch view to plain text mode 

please help me someone whats going wrong in this. Thanks a lot for any help. Sujan