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. MouseButtonRelease does not work on Linux after populating the combo box

MouseButtonRelease does not work on Linux after populating the combo box

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 923 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
    leinad
    wrote on last edited by
    #1

    Hi,

    I have an event Filter for a comboBox. The issue I'm having is when I use MouseButtonRelease and select the drop down arrow, it only catches the signal if there is no data in the combo box. This is true only on Linux/MAC. Once data is loaded the signal is not caught. On windows it works just fine.

    If I use MouseButtonPress then it always works but the dropdown bounces back up after I release the mouse button to make a selection. This is why I prefer to use MouseButtonRelease unless there is a better alternative.

    Any ideas?

    //Assign event filter to the comboBox
    ui->ipStringValueComboBox->installEventFilter(this);

    Further down:
    bool MainWindow::eventFilter(QObject *object, QEvent *event)
    {

    if(event->type() == QEvent::MouseButtonRelease)
    {
    if(object == ui->ipStringValueComboBox)
    IPComboBoxClicked();

    return true;
    }
    else
    return false;

    }

    void MainWindow::IPComboBoxClicked()
    {
    //do some stuff
    ui->ipStringValueComboBox->showPopup();

    }

    Thanks again.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      What do you try to achieve? Why do you need an eventfilter at all?
      You're filtering the event so it will not get delivered to where it should go so this might cause some strange behavior.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • L Offline
        L Offline
        leinad
        wrote on last edited by
        #3

        I need to know when the user clicks on the down arrow of the combo box. I see no signals to handle that so I use an event filter. What is a better way?

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @leinad said in MouseButtonRelease does not work on Linux after populating the combo box:

          I need to know when the user clicks on the down arrow of the combo box.

          Why

          I see no signals to handle that so I use an event filter. What is a better way?

          But then don't filter out the event and let it go to where it belongs.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • L Offline
            L Offline
            leinad
            wrote on last edited by
            #5

            If I understand what you mean, I simply modified the code like this:

            bool MainWindow::eventFilter(QObject *object, QEvent *event)
            {
            Q_UNUSED(event);

                if(object == ui->ipStringValueComboBox)
                        IPComboBoxClicked();
            
                return true;
            

            }

            It compiles but the app does not come up.

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @leinad said in MouseButtonRelease does not work on Linux after populating the combo box:

              It compiles but the app does not come up.

              I would not expect anything else - now every event which is sent to ipStringValueComboBox triggers IPComboBoxClicked() which then calls ui->ipStringValueComboBox->showPopup() ...

              Why do you need this at all?

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • L Offline
                L Offline
                leinad
                wrote on last edited by
                #7

                Ok, so how do I implement when someone clicks on the arrow for ui->ipStringValueComboBox; IPComboBoxClicked() gets called? It should be called once every time the down arrow is clicked. Nothing fancy.

                1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @leinad said in MouseButtonRelease does not work on Linux after populating the combo box:

                  Ok, so how do I implement when someone clicks on the arrow

                  Like you did in your first post, but don't discard the event: QObject::eventFilter()

                  But I still don't see a reason why you should call QComboBox::showPopup() by your own...

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  1
                  • L Offline
                    L Offline
                    leinad
                    wrote on last edited by
                    #9

                    Thank you. think I have it working now.

                    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