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. QComboBox eventFilter move item selection

QComboBox eventFilter move item selection

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

    Hello,

    I have got a problem. I implemented my eventFilter to transform the keyPressed Qt::Key_Down in Qt::Key_Tab.
    What I don't get is that, doing so, it does not move any more the selection of the item in the popup menu, but instead it directly change the document shown in the Widget associated to it.

    here is the code:

    @bool eventFilter(QObject *t, QEvent *e)
    {
    QKeyEvent keyEvent = static_cast<QKeyEvent>(e);
    int key = keyEvent->key();

        if(e->type() == QEvent::KeyPress)
        {
            switch(key)
            {
                case Qt::Key_Backtab:
                {
                    QKeyEvent myEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);
                    QComboBox::keyPressEvent(&myEvent);
                    break;
                }
                case Qt::Key_Tab:
                {
                    QKeyEvent myEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);
                    QComboBox::keyPressEvent(&myEvent);
    

    // int row = this->currentIndex();
    // QString currentItem = this->itemText(row);
    // this->setItemText(row, this->itemText(row+1));
    // this->setItemText(row+1, currentItem);
    break;
    }
    }
    }@

    thanks.

    qxoz: please use code tags

    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