Speed up compilation and make compatible with qt4 (clean version)

This pull request removes inclusions of <QtWidgets> and replaces it with the individual required header files. This is recommended by the QT dev guides to speed up compilation (and it does).

This also has the fortuitous side effect of making the code mostly qt4 compatible. After swapping out the headers, there were only a few places where code differences between qt4 and qt5 needed to be addressed.

This code has been compiled and tested with both qt4 and qt5.