QT rectangle detection