Ported from Qt4 to Qt5