在stack上找到了替代方案,用Qscreen的grabWindow替代了
grabWindow method is now available in QScreen class.
You need to create QScreen object, initialize it with ex. QtGuiApplication.primaryScreen() and then grab the screen
screen.grabWindow(QApplication.desktop().winId())
You should use QScreen::grabWindow() instead. QPixmap::grabWindow() is deprecated in Qt 5.0 because:
there might be platform plugins in which window system identifiers (WId) are local to a screen.