0

I want my QInputDialog input move to the centre like in this VS code windowenter image description here

But i can't move it properly like in the above picture,

Here is my code

import sys
from PyQt6 import QtWidgets, QtGui, QtCore
from PyQt6.QtWidgets import QApplication


class MainWindow(QtWidgets.QMainWindow):

    def __init__(self):

        super().__init__()

        self.setMinimumSize(600, 600)
        self.main_frame = QtWidgets.QFrame(self)
        self.main_layout = QtWidgets.QVBoxLayout(self.main_frame)
        self.setCentralWidget(self.main_frame)

        self.create_ui()

    def create_ui(self):
        self.menu_bar = self.menuBar()

        self.view_menu = QtWidgets.QMenu('View')
        self.backup_menu = QtWidgets.QMenu('Backup')

        self.wakeup_time_backup = QtGui.QAction('Wakeup time')
        self.wakeup_time_backup.triggered.connect(self.open_backup)
        self.backup_menu.addAction(self.wakeup_time_backup)

        self.view_menu.addAction(self.wakeup_time_backup)
        self.menu_bar.addMenu(self.view_menu)

    def open_backup(self):
        wakeup_time_input = QtWidgets.QInputDialog(self, QtCore.Qt.WindowType.Popup)
        wakeup_time_input.setLabelText('Wakeup time')
        wakeup_time_input.setOkButtonText('Save')
        parent_x = self.rect().center().x()
        parent_y = self.rect().center().y()
        wakeup_time_input.move(QtCore.QPoint(parent_x, 10))
        wakeup_time_input.exec()


app = QApplication([])
win = MainWindow()
win.show()

sys.exit(app.exec())

Here is my output enter image description here

I want the QInputDialog to move to the center of mainwinodow and just below the menubar

ABHIJITH EA
  • 308
  • 4
  • 13

0 Answers0