Good afternoon I'm trying to center my app with the following code:
from PyQt5.QtWidgets import QMainWindow,QApplication,QDialog, QDesktopWidget
from PyQt5 import uic, QtCore, QtWidgets
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5 import uic
from PyQt5 import QtCore, Qt, QtGui
import sys
class Principal(QDialog):
def __init__(self):
QDialog.__init__(self)
uic.loadUi("12.ui",self)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setSizeGripEnabled(True)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground,True)
self.frame.resize(2000,1000)
self.frame_2.resize(self.frame.width()-1900,self.frame.height())
self.center()
def mousePressEvent(self,event):
if event.button() == QtCore.Qt.LeftButton:
self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
event.accept()
def mouseMoveEvent(self,event):
if event.buttons() == QtCore.Qt.LeftButton:
self.move(event.globalPos() - self.dragPosition)
event.accept()
def center(self):
qRect = self.frameGeometry()
centerPoint = QDesktopWidget().availableGeometry().center()
print(centerPoint)
qRect.moveCenter(centerPoint)
self.move(qRect.topLeft())
app = QApplication([])
p = Principal()
p.show()
p.resize(1000,600)
app.exec_()
but does not focus the app .. any ideas?