Modified to work with Qt5