Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt : Automatic Mouse Click on X,Y position, using QCoreApplication::sendEvent( this, &click); is not Working.
Forum Updated to NodeBB v4.3 + New Features

Qt : Automatic Mouse Click on X,Y position, using QCoreApplication::sendEvent( this, &click); is not Working.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rkr911
    wrote on last edited by
    #1

    I have Two PushButton on MianWindow, named CreateEvent and Rcreate, I want to Execute on_CreateEvent_pressed() Event of CreateEvent button when i press Rcreate Button.

    I used below Source but its not working.

    Thanks

    @
    mainwindow.cpp

    void MainWindow::on_CreateEvent_clicked()
    {
    QMessageBox::information(this,"Mouse Clicked", "This is Mouse Clicked Event");
    }

    void MainWindow::on_CreateEvent_pressed()
    {
    QMessageBox::information(this,"Mouse Pressed", "This is Mouse Pressed Event");
    }

    void MainWindow::on_Recreate_pressed()
    {
    QPoint pos(95,35); /* Button Position to CreateEvent Log /
    {
    QMouseEvent click(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
    click.setAccepted(true);
    QCoreApplication::sendEvent(this, &click); /
    Tried with ui->CreateEvent also /
    }
    {
    QMouseEvent click(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
    click.setAccepted(true);
    QCoreApplication::sendEvent(this, &click); /
    Tried with ui->CreateEvent also */
    }
    }

    @

    1 Reply Last reply
    0
    • F Offline
      F Offline
      francomartins
      wrote on last edited by
      #2

      try it :
      @
      installEventFilter(this);
      @

      for enable the event filter on MainWindow .

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rkr911
        wrote on last edited by
        #3

        I added it here but still its not working...
        @
        void MainWindow::on_Recreate_pressed()
        {
        installEventFilter(this);
        @

        on other hand i tried with the local position of ui->????, then its woks....

        @
        void MainWindow::reCreate(QObject button) / button = ui->???????? */
        {

        QPoint pos(1,1); /* Local Button Position on main window */
        {
        QMouseEvent click(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
        click.setAccepted(true);
        QCoreApplication::sendEvent(button, &click);
        }
        {
        QMouseEvent click(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
        click.setAccepted(true);
        QCoreApplication::sendEvent(button, &click);
        }
        }

        @

        But I Want to work with global position for ui->???? as i explained earlier...

        Thanks @ regards.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

          Do you seriously want to hardcode widget positions? I can see no reason whatsoever to do so, maybe with the one exception of testing the UI (and even that is a bad idea).

          Why don't you just connect the signals of the Rcreate button to some slots that trigger the functionality you wan?

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rkr911
            wrote on last edited by
            #5

            Actually i want to make operation log for my application, and when ever I want to run this operation log it will run automatically according to recorded co-ordinate.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved