Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
6.4.2
-
None
-
Windows 11, PowerPoint, Python 3.9, PyQt6
Description
I've been working on displaying and editing a PowerPoint-file through a QAxWidget and Active X controls. The display of the pptx-file works as intended, but when clicking on another GUI element like a pushbutton or a lineedit, the pptx-file disappears until you click back into the QAxWidget. I would assume the same behaviour applies to other Microsoft-applications like Word or Excel, but I haven't tested those specifically.
GIF showcasing the issue:
Minimal reproducible example:
import sys from PyQt6.QAxContainer import QAxWidget from PyQt6.QtCore import QEvent from PyQt6.QtWidgets import QWidget, QVBoxLayout, QPushButton, QApplication, QMainWindow class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.menuBar().addMenu("&About") self.centralwidget = QWidget(self) self.centralwidget_vlayout = QVBoxLayout(self.centralwidget) self.axwidget = QAxWidget("PowerPoint.Application") self.axwidget.installEventFilter(self) print(self.axwidget.setControl( r"C:\path\to\presentation.pptx")) self.pushbutton = QPushButton(self.centralwidget) self.pushbutton.setText("Press me!") self.centralwidget_vlayout.addWidget(self.axwidget) self.centralwidget_vlayout.addWidget(self.pushbutton) self.setCentralWidget(self.centralwidget) self.show() self.axwidget.setFocus() def eventFilter(self, widget: QWidget, event: QEvent): if event.type() == QEvent.Type.Resize and widget is self.axwidget: self.axwidget.setFixedHeight(int(self.axwidget.width() / 16 * 9)) return super(MainWindow, self).eventFilter(widget, event) def except_hook(cls, exception, traceback): sys.__excepthook__(cls, exception, traceback) if __name__ == '__main__': sys.excepthook = except_hook app = QApplication(sys.argv) mainWin = MainWindow() sys.exit(app.exec())
There is some more weird behaviour I wanna point out in this minimal reproducible example:
If you remove the line "self.menuBar().addMenu("&About")", which has nothing to the with the QAxWidget, the presentation just won't be displayed? Why? I have another instance where the QAxWidget doesn't display the pptx-presentation, when I remove the applied QFont to the QAxWidgets parent-QGroupBox. I just do not understand this behaviour.
When on the other hand I want to display a PDF instead and declare the QAxWidget-initialization as follows, the PDF remains always visible, even when clicking on the QPushButton:
self.axwidget = QAxWidget("Microsoft Web Browser") self.axwidget.installEventFilter(self) self.axwidget.dynamicCall("Navigate(const QString&)", r"C:\path\to\doc.pdf")
I first noticed this issue using PyQt5, but the behaviour is exactly the same when using PyQt6.
NOTE: As this is my first bug report on anything ever, I am unsure whether I picked the correct "Component/s".