How to find on which outer side of the rectangle falls the point? Qt has a class QRect which tells whether the point is inside the rectangle or not.
Now, the problem is to find out on which outer side (out of four) of the rectangle does the point lie. 
The equation that I already have is:
C++ code:
double m              = (y2 - y1) / (x2 - x1);
double equationResult = (newY - y1) - ((m * newX) + (m * x1));

if (equationResult < 0)
      return "in";
else
      return "out";

where newX and newY are the points which we are supposed to check.
Assumption:
The point lies on the right hand side of the rectangle.
So, with this assumption in mind when I supplied the end points of the top of the rectangle, the result I got was "out".
Even with the end points of the right side, the result I got was "out".  
So, if more than one sides are going to give the same output, how am I supposed to know the position of the point?
 A: I think there's an error in your code.  It seems to me that this will return "in" for points that are below the line, and "out" for points that are on or above the line.  So there is a region outside the rectangle, where you'll actually get "in" for all four lines.  This is aside from the issue of rounding errors that I mentioned in my comment.
Edit:
I think from our conversation in the chat room that you actually want to know which of the four main directions you should move the centre of your square, to most closely approach the target point.  So you want to know whether the X difference or the Y difference is greater.
Write xDifference = xTarget - xCentre and yDifference = yTarget - yCentre.  Then, there are basically four cases.


*

*If xDifference > 0 && xDifference > abs( yDifference ), you want to go to the right.

*If xDifference <= 0 && xDifference < - abs( yDifference ), you want to go to the left.

*If yDifference > 0 && yDifference >= abs( xDifference ), you want to go upwards.

*If yDifference <= 0 && yDifference <= - abs( xDifference ), you want to go downwards.


Note that the differences between <= and < aren't too significant here; likewise the differences between >= and >.  Basically if you need to head exactly north-east, or south-west or whatever to get to your target point, you've got a choice of two directions to head in first.
Please forgive the mixture of C++ notation and mathematical notation that I've used here - I've done this deliberately in the hope that the OP will understand this better.
A: Why not :  $\ \mathrm{in}:=(x_1\le x \le x_2) \land (y_1\le y \le y_2)\ $  ?
(supposing that $x_1\le x_2$ and  $y_1\le y_2$ : i.e. the rectangle is first 'normalized')
Let's illustrate the 9 regions (larger values of $y$ are at the bottom) :

But (from David's discussion +1) perhaps that you are rather interested by these four regions :

with $\ x_c=\dfrac {x_1+x_2}2,\ y_c=\dfrac {y_1+y_2}2$
A: If the point is "out" by checking the lower edge and is out by checking the left edge, then it is obviously posiotioned to the lower-left of the rectangle.
Extending the four sided of the rectangle splits the plane into 9 domains, four of which correspond to only one "out" test and four corresponding to two "out" tests.
