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. generating mouse click to childs
QtWS25 Last Chance

generating mouse click to childs

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 2 Posters 2.1k Views
  • 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.
  • mmcmmcM Offline
    mmcmmcM Offline
    mmcmmc
    wrote on last edited by
    #1

    Hello,
    How can simulte mouse click to any child widget on the QMainWindow, I can generate mouse click on form but there is a pushbutton on (50,50) position but button doesn't receive any signal.
    ps. I'not prefer to use widget name in sendEvent(QWidget....)

    void MainWindow::on_targetbutton_clicked()
    {
        qDebug()<<"click ok";
    }
    
    void MainWindow::on_pushButton_2_clicked()
    {
     QPoint pos(50,50);
     QMouseEvent *mEvnPress;
     QMouseEvent *mEvnRelease;
     mEvnPress = new QMouseEvent(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
     mEvnRelease = new QMouseEvent(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
     QCoreApplication::sendEvent(this,mEvnPress);
     QCoreApplication::sendEvent(this,mEvnRelease);
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      Hi,

      Your position is probably off. IIRC pos will be an absolute position not relative to MainWindow.

      What about just calling the QPushButton::click slot ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      mmcmmcM 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Your position is probably off. IIRC pos will be an absolute position not relative to MainWindow.

        What about just calling the QPushButton::click slot ?

        mmcmmcM Offline
        mmcmmcM Offline
        mmcmmc
        wrote on last edited by
        #3

        Actually the point is not static. I'm trying to get touch coordinates from touch screen (QTouch and this part is ok) and then generate re-calibrated mouse click. So i can produce click on mainwindow but widgets can't get click on that form.

        Could you please give more clue abaout IIRC pos and position is OFF?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You are setting pos at 50, 50 but these coordinates are relative to the MainWindow so you might currently be clicking on an edge of the button. In any case, why not send these events directly to your QPushButton ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • mmcmmcM Offline
            mmcmmcM Offline
            mmcmmc
            wrote on last edited by
            #5

            Because user can touch anywhere in mainwindow. I dont know what type widget can be there or not that moment. I dont need to handle detect widget types and send them signals if i can produce mouse click.
            I wrote 50,50 for sample test and button was very big :) actually.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              There's something not clear here… Why exactly do you need to do that ? Is there a problem with the touchscreen ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • mmcmmcM Offline
                mmcmmcM Offline
                mmcmmc
                wrote on last edited by
                #7

                The coords are not calibrated that i get from touch screen. I'm trying to re-calibrate touch points and generate mouse press/release actions in new coordinates in my app.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Why not recalibrate it ? If using e.g. tslib you have tools that comes with it to calibrate the screen.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • mmcmmcM Offline
                    mmcmmcM Offline
                    mmcmmc
                    wrote on last edited by
                    #9

                    Yes this is may be main approach to solve this. But my app runs in embedded system and i don't want to third party tools (calibrating apps) to calibrate touch screen. I just make it in a settings form. Because my app runs embedded system and it start at power on.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      So you're writing your own calibration tool ?
                      What plugin are you using for the touchscreen input ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • mmcmmcM Offline
                        mmcmmcM Offline
                        mmcmmc
                        wrote on last edited by
                        #11

                        I can detect mouse press/release signals in event filter which i produce at first example. But cant understand why childs cant receive this event, what i'm missing? If i can solve this step my calibrate tool will finish and happilly share codes right here

                        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