Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Eventfilter crashes
Forum Updated to NodeBB v4.3 + New Features

Eventfilter crashes

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kalster
    wrote on last edited by
    #1

    i have an eventfilter event in the mainwindow.cpp. I also have an eventfilter event in the dialog but that is not working. i am wondering can the eventfilter work in two different placing because i am getting no errors but a crash when i try the eventfilter in the dialog.cpp. below is my code.

    dialog.h
    @private slots:
    bool eventFilter(QObject *object, QEvent *event);
    @

    dialog.cpp
    @dialog::dialog(QWidget *parent) :
    QDialog(parent, Qt::CustomizeWindowHint |
    Qt::WindowTitleHint ),
    ui(new Ui::dialog)
    {
    ui->setupUi(this);
    combobox->installEventFilter(this);
    }

    bool dialog::eventFilter(QObject *object, QEvent *event)
    {
    if (object == plainTextEdit && event->type() == QEvent::KeyPress)
    {
    QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
    if (keyEvent->key() == Qt::Key_Return)
    {
    // Special tab handling
    ui->sayButton->animateClick();
    on_sayButton_clicked();
    return true;
    }
    else
    {
    return dialog::eventFilter(object, event);
    }
    }
    else
    {
    return dialog::eventFilter(object, event);
    }
    }@

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Of course it will crash.

      In line 24 and 29 you step into an infinite loop. You're calling the implementation of the eventFilter method of this class. You should call the base class' implementation:

      @
      return QDialog::eventFilter(object, event);
      @

      PS:
      eventFilter is not a slot! It's just an ordinary virtual public method.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved