Details
-
Bug
-
Resolution: Out of scope
-
P4: Low
-
None
-
6.3.1
-
None
Description
When QMainWindow is displayed in full screen, extra pixels will be displayed on another screen.
My Windows PC has two screens connected:
screen_1: 2560x1600 Scale: 150%
screen_2: 3840x2160 Scale: 150%
When I try to display the content in full screen on screen_1, some extra pixels will be displayed on the left side of screen_2, See the pictures in the attachment for details.
The code is as follows:
import sys from PySide6.QtCore import Qt from PySide6.QtGui import QGuiApplication, QKeyEvent from PySide6.QtWidgets import QApplication, QMainWindow class mainwindow(QMainWindow): def __init__(self, screen_num: int = 0, parent=None): super().__init__(parent) self.screen = QGuiApplication.screens()[screen_num] self.setGeometry(self.screen.geometry()) def keyPressEvent(self, event: QKeyEvent): if event.modifiers() == Qt.ControlModifier: if event.key() == Qt.Key_Q: self.close() if __name__ == '__main__': app = QApplication(sys.argv) ui = mainwindow(screen_num=0) ui.showFullScreen() sys.exit(app.exec())
I think this is related to the scaled screen size obtained by pyside.
>>>print(self.screen.geometry(), self.screen.devicePixelRatio()) PySide6.QtCore.QRect(0, 0, 1707, 1067) 1.5
1707x1.5=2560.5 and 2560.5 is approximate to 2561
Maybe the showFullScreen() function should add judgment on the screen range.
If there is a problem with my code or there is a better implementation method, please let me know. I'm sorry to bother you. Thank you!