[Interest] Flush mouse events to a disabled widget!
Lata Agrawal
lata.agrawal at enrouteinc.com
Fri Aug 3 23:42:25 CEST 2012
Hi all,
I have a Dialog with few buttons. When I disable the dialog, and I click on
a child button, nothing happens. But as soon as I enable the Dialog again,
the mouse event for the button is handled.
*Does disabling a Dialog simply delays handling of any mouse events for its
child widgets until enabled again? *
I tried installing event filters for child widgets when dialog is disabled
and then removing the event filters when enabled again. But it provides the
same behavior. As soon as dialog is enabled i.e. event filters for child
widgets removed, the mouse event (when disabled) are handled.
Can someone please help whats wrong here? Here is the code I wrote:
void MyDialog::changeEvent(QEvent *e)
{
if(e->type() == QEvent::EnabledChange)
{
if(isEnabled())
{
qDebug("Filters removed!\n");
ui->pbtnOption1->removeEventFilter(this);
ui->pbtnOption2->removeEventFilter(this);
ui->pbtnOption3->removeEventFilter(this);
}
else
{
qDebug("Filters installed\n");
ui->pbtnOption1->installEventFilter(this);
ui->pbtnOption2->installEventFilter(this);
ui->pbtnOption3->installEventFilter(this);
}
}
}
bool MyDialog::eventFilter(QObject *obj, QEvent *e)
{
if(obj == ui->pbtnOption1 || obj == ui->pbtnOption2 || obj ==
ui->pbtnOption3)
{
if(e->type() == QEvent::MouseButtonPress)
{
qDebug("MousePress Event!\n");
return true;
}
else
return false;
}
return QDialog::eventFilter(obj, e);
}
-- Regards,
Lata
*
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120804/9a5e916b/attachment.html>
More information about the Interest
mailing list