Modified code for Qt5