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. High CPU Usage for Combo Box

High CPU Usage for Combo Box

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 856 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.
  • L Offline
    L Offline
    lucadanieli
    wrote on last edited by
    #1

    Hello,

    looking at the following example,

    @class BoxPopupMenu : public QComboBox
    {

    public:
    BoxPopupMenu(QWidget *parent = 0) :
    QComboBox(parent)
    {
    view()->installEventFilter(this);
    };

    private:
    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)
        {
            switch(key)
            {
                 ...
            }
        }@
    

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

    Luca

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      When eventFilter returns true it "stops processing":http://qt-project.org/doc/qt-5/eventsandfilters.html#event-filters 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.

      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