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

QWidget::underMouse() error

    XMLWordPrintable

Details

    Description

      When a widget gets moved under the mouse (and not the mouse gets moved by the
      user over the widget), then QWidget::underMouse() returns a wrong value - it
      tells me the widget is NOT under the mouse, although it is.

      Attached you find my test application.
      Clicking on the button b1 moves the button b2 to the position where b1 is and
      b1 is set to invisible.
      Now I ask b2::underMouse - and to be sure, I ask after a singleShot timer
      again.

      Both underMouse() calls deliver false, which is wrong.

      This is Qt4.5.2, openSuse 11.1

      example code:

      #include <QApplication>
      #include <QPushButton>
      #include <QTimer>

      QPushButton *b1;
      QPushButton *b2;

      class Object : public QObject
      {
      Q_OBJECT

      public:

      public slots:
      void clicked()

      { qWarning("b1 under mouse:%d", b1->underMouse()); b1->setVisible(false); b2->move(100, 100); qWarning("b2 under mouse:%d", b2->underMouse()); QTimer::singleShot(1000, this, SLOT(later())); }

      void later()

      { qWarning("b2 under mouse:%d", b2->underMouse()); }

      };

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

      Object o;

      QWidget *w = new QWidget;
      b1 = new QPushButton("b1", w);
      b2 = new QPushButton("b2", w);

      b1->move(100, 100);
      b1->connect(b1, SIGNAL(clicked()), &o, SLOT(clicked()));

      w->show();
      return app.exec();
      }

      #include "moc_main.cpp"

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            janichol Andy Nichols
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes