From Kristofer Tingdahl, with additions from Riccardo Corsi and Robert Milharcic, support for Qt5 build