Fixed for PyQt5

Qt4 doesn't have a QtWidgets, but Qt5 does have a QtGui.
Fix QApplication usage
Fix QApplication usage
Fix doctests