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. Focus inside QComboBox
Forum Updated to NodeBB v4.3 + New Features

Focus inside QComboBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 436 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.
  • ivanicyI Offline
    ivanicyI Offline
    ivanicy
    wrote on last edited by ivanicy
    #1

    Hello!

    I have an application that is handled with a joystick.

    I have a list of parameters and one of this parameters is a QComboBox. I am simulating the joystick positions with the letters 'a' (left movement), 'd' (right movement), 'w' (up movement), 's' (down movement) and 'f' (enter).

    There is an eventFilter in which I do all but, when I enter in the QComboBox, I can't navigate between its options. How can I give the focus to the QComboBox entries?

    Thank you very much!

    Pl45m4P 1 Reply Last reply
    0
    • R Offline
      R Offline
      rtvideo
      wrote on last edited by
      #2

      If your questions is how to get certain things inside a QcomboBox for you to select as a dropdown - this should work:

      QComboBox combo;
             QObject::connect(&combo, &QComboBox::currentTextChanged, [&]{
                std::cout << combo.currentText().toStdString() << std::endl;
             });
             for (auto const & info : [whatever the variable is you want to parse goes here])
                ui->comboBox->addItem([the variables you parsed get added here], 0);
      

      For example I used this to get all the cameras that are plugged in to my PC:

      QComboBox combo;
             QObject::connect(&combo, &QComboBox::currentTextChanged, [&]{
                std::cout << combo.currentText().toStdString() << std::endl;
             });
             for (auto const & info : QCameraInfo::availableCameras())
                ui->comboBox->addItem(info.description(), 0);
      
      1 Reply Last reply
      0
      • ivanicyI ivanicy

        Hello!

        I have an application that is handled with a joystick.

        I have a list of parameters and one of this parameters is a QComboBox. I am simulating the joystick positions with the letters 'a' (left movement), 'd' (right movement), 'w' (up movement), 's' (down movement) and 'f' (enter).

        There is an eventFilter in which I do all but, when I enter in the QComboBox, I can't navigate between its options. How can I give the focus to the QComboBox entries?

        Thank you very much!

        Pl45m4P Online
        Pl45m4P Online
        Pl45m4
        wrote on last edited by
        #3

        @ivanicy

        You could navigate through your QComboBox items by using

        https://doc.qt.io/qt-5/qcombobox.html#currentIndex-prop

        Use setCurrentIndex(int) and increase the index, for example, when pressing S (down) and decrease (up), when pressing W.


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        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