Skip to content
Related Articles

Related Articles

move() method in PyQt5

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 26 Mar, 2020

In order to move (changing the position) any widget like buttons or label move() method is used in PyQt5 application. By default, all the widgets are on top left corner therefore, there is a need of changing the position of the widgets.

Syntax : move( x, y )

Arguments : It takes two arguments :
1. X co-ordinate
2. Y co-ordinate

Below is the implementation of this method.

# importing the required libraries
from PyQt5.QtGui import * 
from PyQt5.QtWidgets import * 
import sys
class Window(QMainWindow):
    def __init__(self):
        # set the title
        # setting  the geometry of window
        self.setGeometry(0, 0, 400, 300)
        # creating a label widget
        self.widget = QLabel('Moved', self)
        # moving the widget
        # move(left, top)
        self.widget.move(50, 50)
        # show all the widgets
# create pyqt5 app
App = QApplication(sys.argv)
# create the instance of our Window
window = Window()
# start the app

Output :

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!