Answer the question
In order to leave comments, you need to log in
How to position fullscreen widget in the center of the screen?
The question in itself sounds silly, but nevertheless. We have this code:
class MainWindow(QWidget):
def __init__(self):
super(MainWindow, self).__init__()
self.screenshot = QApplication.primaryScreen().grabWindow(0)
self.settings()
self.create_widgets()
self.set_layout()
def settings(self):
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setWindowState(QtCore.Qt.WindowFullScreen)
def create_widgets(self):
self.image_preview = QLabel()
self.image_preview.setPixmap(self.screenshot)
def set_layout(self):
self.layout = QGridLayout(self)
self.layout.addWidget(self.image_preview, 0, 0, alignment=QtCore.Qt.AlignCenter)
self.setLayout(self.layout)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question