Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-123857

QComboBox does not receive mousePressEvent if item view is opened

    XMLWordPrintable

Details

    Description

      A simple reproducer:

      #include <QApplication>
      #include <QCloseEvent>
      #include <QComboBox>
      #include <QDebug>
      #include <QHideEvent>
      #include <QListWidget>
      #include <QMouseEvent>
      #include <QVBoxLayout>
      
      class MyBox : public QComboBox
      {
      public:
          explicit MyBox()
              : QComboBox{}
          {}
      
      protected:
          void mousePressEvent(QMouseEvent *e) override
          {
              qDebug() << Q_FUNC_INFO << "Mouse pressing";
              QComboBox::mousePressEvent(e);
          }
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          MyBox *cBox = new MyBox;
      
          QListWidget *view = new QListWidget;
          new QListWidgetItem("Item 1", view);
          new QListWidgetItem("Item 2", view);
          new QListWidgetItem("Item 3", view);
          cBox->setModel(view->model());
          cBox->setView(view);
      
          QWidget *main = new QWidget;
          QVBoxLayout *layout = new QVBoxLayout;
          layout->addWidget(cBox);
          main->setLayout(layout);
          main->show();
      
          return a.exec();
      }
      
      #include "main.moc";
      

      Press combo box to open the item view. This press is registered and correctly captured. But another click that closes the item view is not captured. Nothing is output. Don't know how the mousePressEvent that closes the view is handled.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            axelspoerl Axel Spoerl
            luqiaochen Luqiao Chen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes