QObject: use QDebugStateSaver in the QDebug operator<<

Also remove the ending space if the object is null

Change-Id: Ieb2bb903de35b4e339c812cd07555b5d108d118b
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>