title: How to get new coordinate of a widget when window is moved?
body: <p>I have a small dialog like this:</p>
  
  <p><a href="https://i.stack.imgur.com/FCxVP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FCxVP.png" alt="enter image description here"></a></p>
  
  <p>When I move the dialog into another place on the desktop, how can I get the new global coordinate of an element in the dialog (for example, in this case the top left point of the Ok button)?
  Imagine I have a subclass MyButton for the OK button and I want to use QEvent for this class and <strong>I am working in this class, not in QMainWindow.</strong></p>
  
  <pre><code>bool MyButton::eventFilter( QObject *p_obj, QEvent *p_event )
  {     
    if ( p_event-&gt;type() == QEvent::Move )
    {
       QPoint point = this-&gt;contentsRect().topLeft();
       point = mapToGlobal( point );
       qDebug() &lt;&lt; point;
    }
    return QWidget::eventFilter( p_obj, p_event );
  }
  </code></pre>
  
  <p>This function is wrong because the relative position of the button with the dialog never changes, but I dont know how to correct it to get the new <strong>global coordinate</strong> of the button when moving the dialog. <strong>I need the new coordinates continously, not after I release the mouse.</strong> </p>
  
  <pre><code>    gridLayout = new QGridLayout(Form);
      gridLayout-&gt;setObjectName(QStringLiteral("gridLayout"));
      horizontalLayout = new QHBoxLayout();
      horizontalLayout-&gt;setObjectName(QStringLiteral("horizontalLayout"));
      lb_username = new QLabel(Form);
      lb_username-&gt;setObjectName(QStringLiteral("lb_username"));
  
      horizontalLayout-&gt;addWidget(lb_username);
  
      le_username = new QLineEdit(Form);
      le_username-&gt;setObjectName(QStringLiteral("le_username"));
  
      horizontalLayout-&gt;addWidget(le_username);
  
      gridLayout-&gt;addLayout(horizontalLayout, 0, 0, 1, 1);
  
      horizontalLayout_2 = new QHBoxLayout();
      horizontalLayout_2-&gt;setObjectName(QStringLiteral("horizontalLayout_2"));
      lb_password = new QLabel(Form);
      lb_password-&gt;setObjectName(QStringLiteral("lb_password"));
  
      horizontalLayout_2-&gt;addWidget(lb_password);
  
      le_password = new QLineEdit(Form);
      le_password-&gt;setObjectName(QStringLiteral("le_password"));
  
      horizontalLayout_2-&gt;addWidget(le_password);
  
      gridLayout-&gt;addLayout(horizontalLayout_2, 1, 0, 1, 1);
  
      horizontalLayout_3 = new QHBoxLayout();
      horizontalLayout_3-&gt;setObjectName(QStringLiteral("horizontalLayout_3"));
      horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  
      horizontalLayout_3-&gt;addItem(horizontalSpacer);
  
      btn_ok = new MyButton();
      btn_ok-&gt;setObjectName(QStringLiteral("btn_ok"));
  
      horizontalLayout_3-&gt;addWidget(btn_ok);
  
      btn_cancel = new MyButton();
      btn_cancel-&gt;setObjectName(QStringLiteral("btn_cancel"));
  
      horizontalLayout_3-&gt;addWidget(btn_cancel);
  
      gridLayout-&gt;addLayout(horizontalLayout_3, 2, 0, 1, 1);
  
      verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
  
      gridLayout-&gt;addItem(verticalSpacer, 3, 0, 1, 1);
  </code></pre>