我试图设计一个吉卡,以便使用直截面镜加强现实应用。 想法是,利用kin子跟踪探测的手,通过姿态控制申请。
这个问题并不涉及姿态,因为我的评估的这一部分工作是罚款的。
在我的申请中,每当进行点击姿态时,就希望模拟点火。 为了做到这一点,我发出了两场事件,一次是空洞的,一次是空洞的,一次是空洞的,因为通常的点击也是一系列新闻和释放。
The whole thing works fine on a QWebView. In the browser window, i can "click" on links.
But for some reason i cannot "click" on a QPushButton. The clicked() signal is not emitted. I have a short example to illustrate my problem:
First the main function:
int main(int argc, char **argv){
QApplication app( argc, argv );
QWebViewButtons mainapp( 0, Qt::Window );
app.setActiveWindow( &mainapp );
mainapp.show();
mainapp.setApplication( &app ); //this is a setter to also get access to the main application in the widget
return app.exec();
}
This is my own widget:
QWebViewButtons::QWebViewButtons(QWidget* parent, Qt::WindowFlags flags ): QWidget(parent, flags ){
this->m_ui.setupUi( this );
QObject::connect( this->m_ui.pushButton, SIGNAL(clicked(bool)), this, SLOT( buttonClicked(bool) ) );
}
void QWebViewButtons::mousePressEvent( QMouseEvent* event ){
printf("mouse click, %d, %d
", event->pos().x(), event->pos().y() );
}
void QWebViewButtons::buttonClicked( bool clicked ){
printf("slot button clicked
");
}
void QWebViewButtons::keyPressEvent( QKeyEvent* event ){
printf("Key pressed
");
QPoint pos( this->width()/2, this->height()/2 );
QPoint global = this->mapToGlobal(pos);
QWidget *w = this->m_app->widgetAt(global);
//printf("widget under point of click: %s", w);
QApplication::sendEvent( w, new QMouseEvent( QEvent::MouseButtonPress, pos, Qt::MouseButton::LeftButton, Qt::MouseButton::LeftButton, Qt::KeyboardModifier::NoModifier ) );
QApplication::sendEvent( w, new QMouseEvent( QEvent::MouseButtonRelease, pos, Qt::MouseButton::LeftButton, Qt::MouseButton::LeftButton, Qt::KeyboardModifier::NoModifier ) );
}
I followed the suggestion here: Qt Artificial mouse clicks doesnt work properly and send to send my mouse events directly to the QPushButton. But that didn t help. I also tried to send the mouse events to "this", or the main app.
Now I am running out of ideas. What I want to have is, that the buttonClicked() slot is called if i press any key. But i only is called if i click the button with my mouse. How can i accomplish this? Or is my basic idea completely false?
Thanks for your ideas.