Modified for use with Qt5