partial port to qt 5.1.1