I am using Ubuntu 16.04 and Python 2.7. I used PyQt to create a dialog, but how to set the position of a QDialog
object? I tried self.move(x,y)
, but it does not move and still stays in the original position.
This is my example:
class MainWindow(QMainWindow, WindowMixin):
def __init__(self):
super(MainWindow, self).__init__()
self.myDialog = MyDialog(parent=self)
def createMyDialog(self):
self.myDialog.popUp(x=self.geometry().x(), y=self.geometry().y(), width=self.geometry().width(), height=self.geometry().height())
class MyDialog(QDialog):
def __init__(self, parent=None):
super(LabelDialog, self).__init__(parent)
def popUp(self, x="", y="", width="", height=""):
if (x!="") and (y!="") and (width!="") and (height!=""):
# self.resize(width/6, 20)
self.move(0, 0)
I use the createMyDialog
function to create the modal dialog. Can anyone give any advice?