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

Calling grabMouse on a widget does not work when the mouse is moved outside the application window - Mac OS X

XMLWordPrintable

    • macOS

      Calling grabMouse on a widget does not work when the mouse is moved outside the application window Mac OS X.
      This is not going to work with Cocoa, but should probably work with Carbon.
      On Windows and X11 it works like expected.

      #include <QApplication> 
      #include <QMainWindow> 
      #include <QToolBar> 
      #include <QAction> 
      
      #include <stdio.h> 
      #include <time.h> 
      
      class test: public QMainWindow 
      { 
      Q_OBJECT; 
      
      public: 
      test() :QMainWindow() 
      { 
          mToolBar = new QToolBar(this); 
          addToolBar(mToolBar); 
      
          mTest = new QAction(this); 
          mTest->setText("test2"); 
          connect (mTest, SIGNAL(triggered()), 
          this, SLOT(onClicked())); 
          mToolBar->addAction(mTest); 
      
          setMouseTracking(true); 
      } 
      
      protected: 
      void mouseMoveEvent ( QMouseEvent * /* event */ ) 
      { 
          printf("mouse move event %x\n", (int)time(0)); 
      } 
      
      public slots: 
      void onClicked() 
      { 
          grabMouse(); 
      } 
      private: 
          QAction *mTest; 
          QToolBar *mToolBar; 
      }; 
      
      int main(int argc, char *argv[]) 
      { 
          QApplication app (argc, argv); 
          test mw; 
          mw.show(); 
          return app.exec(); 
      } 
      
      #include "moc_qttest.cpp"
      

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

            sorvig Morten Sørvig
            sanonymous Nokia Qt Support (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes