[Solved]Calender Popup issue.
My requirement is to show --/--/---- in the QDateEdit as default, now after this when the user clicks on the down arrow the calender should popup with the current date, and the user should be able to select any date.
Now to set --/--/---- I am using
this will show only when the set date is invalid, or doesnot lie in the range, so for that I am setting the date as 1,1,1 using
After this when the user clicks on the down arrow the popup comes but it comes up with the year as 1752.
Now I need calender popup to show the current date instead of this. I have checked lot but could not find any thing, and there is no signal that is being emitted when the QTimeEdit is clicked.
Please let me know how can I proceed with this.
you can do the following to check if the user clicks on the popup button:
void MyTimeEdit::mousePressEvent(QMouseEvent* event)
QRect rect = this->style()->subControlRect(QStyle::CC_ComboBox,&opt,QStyle::SC_ComboBoxArrow);
.... //do your stuff here
Thanks for the reply, from you post I actually got the hint how to proceed.
The approach I used is a bit different but it works well for me. I would like to share what I actually did.
@bool QDateEdit::eventFilter(QObject *target, QEvent *event)
if (event->type()== QEvent::MouseButtonPress)
QMouseEvent *mevent = static_cast<QMouseEvent *>(event);
if(mevent != NULL)
if(mevent->buttons() == Qt::LeftButton)
if (date() == minimumDate())