Refactor qt import logic. Fixes #2955