generating mouse click to childs
-
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); }
-
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 ?
-
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 ?
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?
-
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 ?
-
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. -
There's something not clear here⦠Why exactly do you need to do that ? Is there a problem with the touchscreen ?
-
Why not recalibrate it ? If using e.g. tslib you have tools that comes with it to calibrate the screen.
-
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.
-
So you're writing your own calibration tool ?
What plugin are you using for the touchscreen input ? -
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