Hello,

does anyone know a way to detect if a pointer to a subclass of QObject or even a QWidget is dangling?

Qt Code:
  1. class MyWidget : public QWidget;
  2.  
  3. MyWidget w = new MyWidget(parent);
  4.  
  5. somewhere()
  6. {
  7. delete w;
  8. }
  9.  
  10. somewhereelse()
  11. {
  12. if (w is not dangling) // <-- how to do this?
  13. do something with w;
  14. }
To copy to clipboard, switch view to plain text mode 

I know that you can connect the destroyed() signal, but in my case it's very tiresome. It would be much nicer (and safer) if I could somehow tell by the pointer, if it still points to a valid object or not. Is there such a path to take, oh masters of Qt?