Open In App

PyQt5 QDateTimeEdit – Setting Layout Direction

Last Updated : 14 Jul, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

In this article we will see how we can set layout direction of the QDateTimeEdit widget. Layout direction specifies the direction of the QDateTime, by default the arrow buttons which increment or decrement date time are on the right-hand side although by setting layout direction, they can appear on the left-hand side.

In order to do this we will use setLayoutDirection method with the QDateTimeEdit object.

Syntax : datetimeedit.setLayoutDirection(Qt.RightToLeft)

Argument : It takes direction object as argument

Return : It returns None

Below is the implementation




# importing libraries
from PyQt5.QtWidgets import * 
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import * 
from PyQt5.QtCore import * 
import sys
  
  
class Window(QMainWindow):
  
    def __init__(self):
        super().__init__()
  
        # setting title
        self.setWindowTitle("Python ")
  
        # setting geometry
        self.setGeometry(100, 100, 500, 400)
  
        # calling method
        self.UiComponents()
  
        # showing all the widgets
        self.show()
  
    # method for components
    def UiComponents(self):
  
        # creating a QDateTimeEdit widget
        datetimeedit = QDateTimeEdit(self)
  
        # setting geometry
        datetimeedit.setGeometry(100, 100, 150, 35)
  
        # setting layout direction
        datetimeedit.setLayoutDirection(Qt.RightToLeft)
  
        # creating a label
        label = QLabel("GeeksforGeeks", self)
  
        # setting geometry to the label
        label.setGeometry(100, 160, 200, 60)
  
        # making label multi line
        label.setWordWrap(True)
  
  
  
  
# create pyqt5 app
App = QApplication(sys.argv)
  
# create the instance of our Window
window = Window()
  
# start the app
sys.exit(App.exec())


Output :



Similar Reads

PyQt5 QDateTimeEdit – Getting Layout Direction
In this article we will see how we can get layout direction of the QDateTimeEdit widget. Layout direction specifies the direction of the QDateTime, by default the arrow buttons which increment or decrement date-time are on the right-hand side although by setting layout direction with the help of setLayoutDirection method, they can appear on the lef
2 min read
PyQt5 QDateTimeEdit – Clearing Layout Direction Property
In this article we will see how we can remove/clear the selected layout direction of the QDateTimeEdit widget. Clearing layout direction will revert back layout direction to the default. Layout direction specifies the direction of the QDateTime, by default the arrow buttons which increment or decrement date-time are on the right-hand side although
2 min read
PyQt5 QDockWidget – Setting Layout Direction
In this article we will see how we can set the layout direction to the QDockWidget. QDockWidget provides the concept of dock widgets, also know as tool palettes or utility windows. Dock windows are secondary windows placed in the dock widget area around the central widget in a QMainWindow(original window). Layout specifies how the children get arra
2 min read
PyQt5 QDateTimeEdit - Setting QDateTime to it
In this article we will see how we can set QDateTime object to the QDateTimeEdit widget. QDateTime is basically a combination of QDate and QTime i.e it has both date and time. And QDateTimeEdit widget is used to show or receive the QDateTime. In order to do this we will use setDateTime method with the QDateTimeEdit object. Syntax : datetimeedit.set
2 min read
PyQt5 QDateTimeEdit – Setting only QDate
In this article we will see how we can set only QDate to the QDateTimeEdit widget. QDateTime is basically a combination of QDate and QTime i.e it has both date and time. And QDateTimeEdit widget is used to show or receive the QDateTime. We can set QDateTime to it with the help of setDateTime method. Setting date will not affect the time of the QDat
2 min read
PyQt5 QDateTimeEdit – Setting only QTime
In this article we will see how we can set only QTime to the QDateTimeEdit widget. QDateTime is basically a combination of QDate and QTime i.e it has both date and time. And QDateTimeEdit widget is used to show or receive the QDateTime. We can set QDateTime to it with the help of setDateTime method. Setting time will not affect the date of the QDat
2 min read
PyQt5 QDateTimeEdit – Setting maximum QDateTime
In this article we will see how we can set maximum QDateTime to the QDateTimeEdit widget. QDateTime is basically a combination of QDate and QTime i.e it has both date and time. And QDateTimeEdit widget is used to show or receive the QDateTime. We can set date time to it with the help of setDateTime. By setting maximum value of it make sure that use
2 min read
PyQt5 QDateTimeEdit – Setting minimum QDateTime
In this article we will see how we can set the minimum QDateTime of the QDateTimeEdit widget. QDateTime is basically a combination of QDate and QTime i.e it has both date and time. And QDateTimeEdit widget is used to show or receive the QDateTime. We can set date time to it with the help of setDateTime. By setting minimum value of it make sure that
2 min read
PyQt5 QDateTimeEdit – Setting QDateTime Range
In this article we will see how we can set QDateTime range of the QDateTimeEdit widget. QDateTime is basically a combination of QDate and QTime i.e it has both date and time. And QDateTimeEdit widget is used to show or receive the QDateTime. We can set date time to it with the help of setDateTime. By setting range to it, make sure that user will is
2 min read
PyQt5 QDateTimeEdit – Setting Wrapping Property
In this article we will see how we can set wrapping property of the QDateTimeEdit widget. QDateTime is basically a combination of QDate and QTime i.e it has both date and time. And QDateTimeEdit widget is used to show or receive the QDateTime. Wrapping property makes stepping up from maximum date time will take user to the minimum date time and vic
2 min read