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 focus is not shown with Gray dotted line border when Enter/Return key is pressed
Qt 6.11 is out! See what's new in the release blog

QComboBox focus is not shown with Gray dotted line border when Enter/Return key is pressed

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

    Hi...

    I have a QLineEdit and a QComboBox, when the Focus is in the QLineEdit and if i press Enter/Return key the focus has to be changed to the QComboBox. I tried using event filters and the focus is changing to the QComboBox, but the problem is when the focus is in the QComboBox, it is not showing with the Dotted lines border.... Again if i press Enter the focus has to be changed to the QLineEdit. This one is also not working. Please post your suggestions..
    @
    if(keyEvent->key() == Qt::Key_Enter || keyEvent->key()== Qt::Key_Return)
    {
    this->focusNextChild();
    }
    @

    Note: It works Fine if i press the Tab key for changing the Focus.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Macro
      wrote on last edited by
      #2

      Hi...

      This code works Fine for changing the focus from the Last Component(QComboBox) to the First Component (QLineEdit). But Still that Dotted Lines Border for the QComboBox (when it has the Focus) is not Working.. Please post your suggestions....

      @bool ComboFocus::eventFilter(QObject *obj, QEvent *event)
      {
      if(event->type() == QEvent::KeyPress)
      {
      QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
      if(keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return)
      {
      if(children().indexOf(obj) == children().count()-1)
      {
      QWidget firstwidget = qobject_cast<QWidget>(children().at(0));
      if(firstwidget != NULL)
      {
      firstwidget->setFocus();
      }
      else
      {
      this->focusNextChild();
      }
      }
      else
      {
      this->focusNextChild();
      }

              return QWidget::eventFilter(obj, event);
          }
      }
      

      }@

      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