Port to Qt5 and tweak to make it work