title: Crash on keyPressEvent
body: <p>I'm creating a program that draws colours then another class checks them and returns true if they match. The whole code of which is in a dialog. colQ is a class that simply stores RGB values and other things; we'll be using these to get the RGBs.</p>
  
  <pre><code>colDialog::colDialog(QWidget *parent) // etc..
  {
    // initialization code
  
      colQ.setColor(255, 0, 0); // red
      r_ans = g_ans = b_ans = nullptr;
  }
  </code></pre>
  
  <p>I then have a paint event that does the drawing. r1 and br1 are pointers to their respective classes.</p>
  
  <pre><code>void Atn_QDialog::paintEvent(QPaintEvent *e)
  {
      QPainter painter(this);
  
      r1 = new QRect(100, 100, 175, 400);
      br1 = new QBrush(QColor(colQ.getR, colQ.getG, colQ.getB));
      painter.fillRect(*r1, *br1);
      painter.drawRect(*r1);
  
      // other color code
  }
  </code></pre>
  
  <p>At this point, I would have a rectangle drawn with the colour red. What I want to do now is have the user press a key (like 1) and then colQ will then check whether the color stored matches the one on the rectangle to which the key is pressed.</p>
  
  <pre><code>void colDialog::keyPressEvent(QKeyEvent *Ev)
  {
      if (Ev-&gt;key() == Qt::Key_1)
      {
           br1-&gt;color().getRgb(r_ans, g_ans, b_ans);
           colQ.answer(*r_ans, *g_ans, *b_ans);
  
           if (colQ.isCorrect())
                ui-&gt;resultlabel-&gt;setText("correct!");
           else ui-&gt;resultlabel-&gt;setText("wrong!"); 
      }
  
      // other key presses here
      QDialog::keyPressEvent(Ev);
  }
  </code></pre>
  
  <p>The bug occurs when I press the '1' key where the code has thus far been implemented. Before, pressing the key responds fine but it doesn't when this code is run. Fyi, colQ has NO Qt code, and ommitting the code thereof still causes my program to crash. What I'm doing here is I want to get the color stored in br of type QBrush*. I passed pointers into getRgb(..) as that was what's asked for. The code crashes effectively on keyPressEvent(Ev); things like ui->resultlabel-~>setText("...") don't cause the program to crash on key presses. It only occurs with the foresaid function calls.</p>