[Solved]Activating calender popup on focus in event
I have a requirement in which I want to activate the calender popup using the keyboard. But the problem is that, in the focus in event the popup doesn't work.
Please let me know if I need to change the approach or add something more that I am missing.
see my DocNote on the "QTimeEdit":http://qt-project.org/doc/qt-4.8/qdatetimeedit.html. You could do something like that in your focus event handler method:
void MyDateEdit::focusInEvent ( QFocusEvent * event )
QRect rect = this->style()->subControlRect(QStyle::CC_ComboBox,&opt,QStyle::SC_ComboBoxArrow);
QMouseEvent event(QEvent::MouseButtonPress, rect.center(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QApplication::sendEvent(this, &event); QMouseEvent event(QEvent::MouseButtonRelease, rect.center(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QApplication::sendEvent(this, &event); QDateEdit::focusInEvent(event);
this should open the calendar popup on focus in.
Since dateEdit inherits QAbstractSipnBox: you need to make few modification to the above code,
QRect rect = this->style()->subControlRect(QStyle::CC_SpinBox,&opt,QStyle::SC_SpinBoxDown);@
no, because when the calendar popup is enabled the time edit looks more like a combobox than a spinbox right?
And thats even the code QDateTimeEdit uses itself to paint the calendar button internally btw.
But the code didnt work with QStyleOptionComboBox.
yes you are right.. .sorry.
It over-hasted when i looked it up from some old code of mine.
It happens no worries :)