Neste artigo, veremos como obtemos o filho de QCalendarWidget na coordenada / posição fornecida. O calendário não é um único widget sozinho, é uma mistura de muitos widgets menores que chamamos de filho do calendário. Existem muitos filhos, como visão de tabela, delegação de item etc.

Para fazer isso, usaremos o childAtmétodo com o objeto QCalendarWidget.

Sintaxe: calendar.childAt (x, y)

Argumento: leva dois inteiros como argumento

Retorno: Retorna filho do calendário em determinada posição



Abaixo está a implementação

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, 600, 400) 
        self.UiComponents() 
        self.show() 
  
    
    def UiComponents(self): 
        self.calender = QCalendarWidget(self) 
        self.calender.setGeometry(50, 10, 400, 250) 
        label = QLabel(self) 
        label.setGeometry(120, 280, 200, 60) 
        label.setWordWrap(True) 
        value = self.calender.childAt(10, 10) 
        label.setText("Child : " + str(value)) 
  
  
  
App = QApplication(sys.argv) 
window = Window() 
  
  
sys.exit(App.exec()) 

Resultado :