Adapted to Qt5