Hi, everyone!
I'm getting a SegFault while implement an eventFilter in a QDialog subclass.
The code bellow works fine in Qt 4.8.6, in Qt 5.3.1 it Segfault.
{
setGeometry(0, 0, 768, 450);
this->installEventFilter(this);
}
{
if (event
->type
() == QEvent::KeyPress) {
if ((keyEvent->key() == Qt::Key_Return) || (keyEvent->key() == Qt::Key_Enter)) {
ISCBase *base = qobject_cast<ISCBase*>(object);
if (
(base) && (
(qobject_cast<QRadioButton*>(base->focusWidget())) ||
(qobject_cast<QCheckBox*>(base->focusWidget())) ||
(qobject_cast<QComboBox*>(base->focusWidget())) ||
(qobject_cast<QDateEdit*>(base->focusWidget())) ||
(qobject_cast<QDoubleSpinBox*>(base->focusWidget())) ||
(qobject_cast<QFontComboBox*>(base->focusWidget())) ||
(qobject_cast<QSlider*>(base->focusWidget())) ||
#if QT_VERSION >= 0x050000
(qobject_cast<QKeySequenceEdit*>(base->focusWidget())) ||
#endif
(qobject_cast<QLineEdit*>(base->focusWidget())) ||
(qobject_cast<QRadioButton*>(base->focusWidget())) ||
(qobject_cast<QSpinBox*>(base->focusWidget())) ||
(qobject_cast<QTimeEdit*>(base->focusWidget())))
) {
focusNextChild();
return true;
}
}
}
return QObject::eventFilter(object, event
);
}
ISCBase::ISCBase(QWidget *parent) : QDialog(parent)
{
setGeometry(0, 0, 768, 450);
this->installEventFilter(this);
}
bool ISCBase::eventFilter(QObject *object, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = (QKeyEvent*) event;
if ((keyEvent->key() == Qt::Key_Return) || (keyEvent->key() == Qt::Key_Enter)) {
ISCBase *base = qobject_cast<ISCBase*>(object);
if (
(base) && (
(qobject_cast<QRadioButton*>(base->focusWidget())) ||
(qobject_cast<QCheckBox*>(base->focusWidget())) ||
(qobject_cast<QComboBox*>(base->focusWidget())) ||
(qobject_cast<QDateEdit*>(base->focusWidget())) ||
(qobject_cast<QDoubleSpinBox*>(base->focusWidget())) ||
(qobject_cast<QFontComboBox*>(base->focusWidget())) ||
(qobject_cast<QSlider*>(base->focusWidget())) ||
#if QT_VERSION >= 0x050000
(qobject_cast<QKeySequenceEdit*>(base->focusWidget())) ||
#endif
(qobject_cast<QLineEdit*>(base->focusWidget())) ||
(qobject_cast<QRadioButton*>(base->focusWidget())) ||
(qobject_cast<QSpinBox*>(base->focusWidget())) ||
(qobject_cast<QTimeEdit*>(base->focusWidget())))
) {
focusNextChild();
return true;
}
}
}
return QObject::eventFilter(object, event);
}
To copy to clipboard, switch view to plain text mode
Any help will be welcome.
Bookmarks