For example, is there any potential risk in the following code?
Qt Code:
  1. // when re-implement QCalendarWidget's functions
  2. QObjectList children_of_this = this->children();
  3. //this points to QCalendarWidget
  4. for( int i = 0; i < children_of_this.count(); i++)
  5. {
  6. if(children_of_this.at(i)->objectName() == "qt_calendar_navigationbar")
  7. {
  8. navigator = qobject_cast<QWidget*>(children_of_this[i]);
  9. if(navigator)
  10. {
  11. // do something to navigator's layout
  12. }
  13. //navigator is a pointer to a QWidget, which is previous NULL
  14. if(children_of_this.at(i)->objectName() == "qt_calendar_calendarview")
  15. {
  16. view = qobject_cast<QTableView*>(children_of_this[i]);
  17. if(view)
  18. {
  19. view->setItemDelegate(new QStyledItemDelegate);
  20. }
  21. }
  22. //view is a pointer to a QTableView which is previous NULL
  23. }
To copy to clipboard, switch view to plain text mode 

and in the "qcalendarwidget.cpp", the Qt's source code:
Qt Code:
  1. //i want to access objects like this
  2. d->m_view->setObjectName(QLatin1String("qt_calendar_calendarview"));
  3.  
  4. navBarBackground = new QWidget(widget);
  5. navBarBackground->setObjectName(QLatin1String("qt_calendar_navigationbar"));
To copy to clipboard, switch view to plain text mode 

I'm quite new to both Qt and C++ and wondering whether or not it is right to get the objects pointers those are not exposed to users.