In this article we will see how we can get the section count of the QDateTimeEdit widget. There are many sections in the QDateTimeedit widget like, year, month, hour, minute section. User can select any section with the help of mouse or keyboard and increment and decrement action get performed on the selected section.
In order to do this we will use sectionCount
method with the QDateTimeEdit object.
Syntax : datetimeedit.sectionCount()
Argument : It takes no argument
Return : It returns integer
Below is the implementation
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__()
self .setWindowTitle( "Python " )
self .setGeometry( 100 , 100 , 500 , 400 )
self .UiComponents()
self .show()
def UiComponents( self ):
datetimeedit = QDateTimeEdit( self )
datetimeedit.setGeometry( 100 , 100 , 150 , 35 )
label = QLabel( "GeeksforGeeks" , self )
label.setGeometry( 100 , 200 , 200 , 60 )
label.setWordWrap( True )
value = datetimeedit.sectionCount()
label.setText( "Section Count : " + str (value))
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
14 Jul, 2020
Like Article
Save Article