[qt] use qobject_cast when possible, seems to avoid some crash