In my project I'm having a hash member of :

Qt Code:
  1. QHash<int,graphDialog *> dialogs;
To copy to clipboard, switch view to plain text mode 

where graphDialog class is a member of QDialog.

while I'm iterating through this hash, I want to make sure that the QDialog member I'm iterating is not null ( not destroyed ).
How do I do that?
I tried the following :

Qt Code:
  1. QHashIterator<int, graphDialog *> i(dialogs);
  2. while (i.hasNext()) {
  3. i.next();
  4. if(i.value() != NULL ){ ... }
  5. }
To copy to clipboard, switch view to plain text mode 
although when the dialog is destroyed it is not equal to NULL and passes through if :/

then I used the so-called guarded pointer class QPointer and did the following:

Qt Code:
  1. QHashIterator<int, graphDialog *> i(dialogs);
  2. while (i.hasNext()) {
  3. i.next();
  4. QPointer<graphDialog> test = i.value();
  5. if(!test){ .... }
  6. }
To copy to clipboard, switch view to plain text mode 
however this time I get a segmentation error while the QPointer is being created.
I thought this class was meant to build for this mission, but it seems to suffer from the same issue (null reference).

also there is nothing like isClosed,isDestroyed,isNull for QDialog if I'm not mistaken ...
So how do I check for it , please help