This is my code
void CommonFunctions
::progressbar(QString Dialogtext
) {
l->setWordWrap(true);
progress->setWindowModality(Qt::WindowModal);
progress->setRange(0,10);
layout->addWidget(l);
layout->addWidget(progress,Qt::AlignCenter);
win->setMaximumWidth(320);
win->setModal(true);
win->setLayout(layout);
win->setWindowTitle("title");
installEventFilter(win);
win->setWindowFlags(Qt::Dialog|Qt::WindowMaximizeButtonHint);
win->show();
}
{
if (event
->type
() == QEvent::KeyPress) { QKeyEvent *keyEvent
= static_cast<QKeyEvent
*>
(event
);
if (keyEvent->key() == Qt::Key_Escape) {
keyEvent->ignore();
return true;
} else
return false;
}
return false;
}
void CommonFunctions::progressbar(QString Dialogtext)
{
layout = new QVBoxLayout;
l = new QLabel( Dialogtext);
l->setWordWrap(true);
progress = new QProgressBar();
progress->setWindowModality(Qt::WindowModal);
progress->setRange(0,10);
layout->addWidget(l);
layout->addWidget(progress,Qt::AlignCenter);
win->setMaximumWidth(320);
win->setModal(true);
win->setLayout(layout);
win->setWindowTitle("title");
installEventFilter(win);
win->setWindowFlags(Qt::Dialog|Qt::WindowMaximizeButtonHint);
win->show();
}
bool QDialog::eventFilter(QObject *object, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Escape) {
keyEvent->ignore();
return true;
} else
return false;
}
return false;
}
To copy to clipboard, switch view to plain text mode
i had checked this code by setting a breakpoint in eventFilter(), while pressing Esc key debugger stops at break point and checks the condition in 22 line of the above code , but it fails & returns false
where im getting wrong can anybody help me....
Bookmarks