title: Qt throws error when allocating too much dynamic memory within a class
body: <p>I have a class where I allocate some memory. For Example:</p>
  
  <pre><code>class image {
  
  public:
      image(){
          pixelvalue = 0;
      }
  
      void formatandcopy() {
          pixelvalue = new int [10000*50000];
          if(pixelvalue)
              qDebug()&lt;&lt;"allocation successful"; 
          else 
              qDebug()&lt;&lt;"allocation failed";
      }
  private:
      int *pixelvalue;
  };
  </code></pre>
  
  <p>When I call <code>formatandcopy()</code> the program throws this:</p>
  
  <pre><code>Qt has caught an exception thrown from an event handler. Throwing
  exceptions from an event handler is not supported in Qt. You must
  reimplement QApplication::notify() and catch all exceptions there.
  </code></pre>
  
  <p>Anyone know how I can prevent this and let the user know it's simply out of memory? When I run this it doesn't even show <code>allocation failed</code>. The above error is thrown before the <code>qDebug()</code> is called. The program runs fine if the amount of memory allocated is decreased. I thought this was strange since this error is thrown when using the <code>new</code> operator and not a qt function. Furthermore my machine has plenty of memory left. I assume this is a result of qt limiting it's program to a certain heap space. Lastly, if I can fix this by indeed reimplementing the <code>notify</code> function then can anyone point me in the right direction to do this?</p>