Open In App

PyQt5 QDateTimeEdit – Getting Layout Direction

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

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 left-hand side.

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

Syntax : datetimeedit.layoutDirection()

Argument : It takes no argument

Return : It returns direction object but when printed it shows the value associated with it

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)
  
        # getting layout direction
        value = datetimeedit.layoutDirection()
  
        # setting text to the label
        label.setText("Layout Direction " + str(value))
  
  
  
# 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 – Setting Layout Direction
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 us
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 – Getting Layout Direction
In this article we will see how we can get the layout direction of 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 - Getting QDateTime
In this article we will see how we can get QDateTime object 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 QDateTime to it with the help of setDateTime method. In order to do this we will use dateTime me
2 min read
PyQt5 QDateTimeEdit – Getting only QDate
In this article we will see how we can get only QDate 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 QDateTime to it with the help of setDateTime method. Setting date will not affect the time of the QDat
2 min read
PyQt5 QDateTimeEdit – Getting only QTime
In this article we will see how we can get only QTime 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 QDateTime to it with the help of setDateTime method. Setting time will not effect the date of the QDat
2 min read
PyQt5 QDateTimeEdit – Getting maximum QDateTime
In this article we will see how we can get maximum 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 maximum value of it make sure that use
2 min read
PyQt5 QDateTimeEdit – Getting minimum QDateTime
In this article we will see how we can get 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 – Getting Wrapping Property
In this article we will see how we can get 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
PyQt5 QDateTimeEdit – Getting Special Date Time Text
In this article we will see how we can get special date time text of the QDateTimeEdit widget. By setting special text with the help of setSpecialValueText method, the QDateTimeEdit display this special text instead of a date time value whenever the current value is equal to minimum date time. In order to do this we will use specialValueText method
2 min read