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

QLabel event propagation when displaying rich text

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3: Somewhat important P3: Somewhat important
    • 4.6.0
    • None
    • Core: Event loop
    • None

      A QLabel which displays rich text doesn't propagate its mouse events properly to its parent. I found this on win32-msvc2005.

      -snip---------------------------
      class MyWidget : public QWidget
      {
      public:
      MyWidget(QString txt)

      { QLabel* lbl = new QLabel(this); lbl->setText(txt); lbl->show(); }

      void mousePressEvent(QMouseEvent* e)

      { close(); }

      };

      int main(int argc, char* argv[])
      {
      QApplication app(argc, argv);

      MyWidget* lblPlain = new MyWidget("click me to close");
      lblPlain->show();
      MyWidget* lblRich = new MyWidget("click <b>me</b> to close");
      lblRich->show();

      return app.exec();
      }
      -snap---------------------------

      This example shows two widgets, each containing a QLabel.
      Widget lblPlain holds a plain text string, lblRich a rich text string.
      One can click on the text in lblPlain and the widget closes as expected.
      If you click on lblRich then nothing happens... you need a double click to get rid of it.

      It seems that ensureTextControl is the source of the problem. AFAICS the mouse event is sent to the text control.

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

            vfm Thierry Bastian (closed Nokia identity) (Inactive)
            jbornema Joerg Bornemann
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes