Figure out an if else

In the example code these 2 lines and the readQD() function put a value in the QRE_Value variable and print it.

  int QRE_Value = readQD();
  Serial.println(QRE_Value);

It is the QRE_Value variable that you need to test the value of to determine whether something was detected or not. Try printing it as in the example code to see what values you are actually getting and when.