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

QLabel with rich text (HTML) does not pass mouseReleaseEvent to parent

    XMLWordPrintable

Details

    • All
    • 7689d4ad2 (dev), c5479c9b2 (6.4), 5baf64466 (6.5), 593ffd385 (dev), 379649dd8 (6.4), 0c8335575 (6.5)

    Description

      Consider the following code:

      #include <QApplication>
      #include <QDebug>
      #include <QLabel>
      #include <QVBoxLayout>
      
      class Widget : public QWidget
      {
      protected:
          void mousePressEvent(QMouseEvent *event) override
          {
              qInfo() << "pressed" << event;
          }
      
          void mouseReleaseEvent(QMouseEvent *event) override
          {
              qInfo() << "released" << event;
          }
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          Widget w;
          auto layout = new QVBoxLayout(&w);
          auto label1 = new QLabel("<b>rich text DOES NOT pass mouse release event to parent</b>");
          layout->addWidget(label1);
          auto label2 = new QLabel("plain text DOES pass mouse release event to parent");
          layout->addWidget(label2);
          w.show();
          return a.exec();
      }
      

      When clicking on the plain text label, BOTH mouse press and mouse release events are passed to the parent and written to console.

      But when clicking on the rich text (HTML formatted) label, ONLY mouse press event is passed to the parent. Mouse release event gets lost somewhere.

      This is a very surprising behaviour and as such I assess it to be a bug.

      Attachments

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

        Activity

          People

            axelspoerl Axel Spoerl
            vladimir.kraus Vladimir Kraus
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: