Important: Please read the Qt Code of Conduct -

High CPU Usage for Combo Box

  • Hello,

    looking at the following example,

    @class BoxPopupMenu : public QComboBox

    BoxPopupMenu(QWidget *parent = 0) :

    bool eventFilter(QObject *t, QEvent *e)
    return true;

    I have seen that eventFilter function intensifies my CPU usage to 50%.
    Inside this function I have written:

    @ QKeyEvent keyEvent = static_cast<QKeyEvent>(e);
    int key = keyEvent->key();

        if(e->type() == QEvent::KeyPress)

    The problem persists in both the examples.
    Do you know what could be the problem?


  • When eventFilter returns true it "stops processing": of the events. But the events continue to come so an empty eventFilter takes all CPU.
    You need to return false from eventFilter to let Qt to process the events which are not interesting for your eventFilter.

Log in to reply