Implementing Snap-To-Edge Functionality
Definitely extract method for the following code:

if ( rtChild.right() &lt; rtParent.left() )
{
    if ( ( ( rtParent.left() - rtChild.right() ) &lt;= ENABLE_STICK_VALUE )
        &amp;&amp; ( rtChild.top() &gt;= ( rtParent.top() - ENABLE_STICK_VALUE ) )
        &amp;&amp; ( rtChild.top() &lt;= ( rtParent.bottom() + ENABLE_STICK_VALUE ) ) )
    {
        isNear = true;
        ptMoveTarget = QPoint( rtParent.left() - rtChild.width() , rtParent.top() );
    }
}


Where you can pass through a left/right variable however you want and then change:

rtParent.left() - rtChild.width() to rely on the given parameter, falling back onto rtParent.right()

The same can be said for any other small changes in the code, such as

rtChild.right() &lt; rtParent.left()
versus
rtChild.left() &gt; rtParent.right()

I'm not going to give you the exact solution, but that if condition holds most of the repeated code and can be brought out into something like snapTo(right/left)