Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Qt中打开子窗口时监视父窗口中的事件_Qt_Events_Kiosk_Childwindow_Kiosk Mode - Fatal编程技术网

在Qt中打开子窗口时监视父窗口中的事件

在Qt中打开子窗口时监视父窗口中的事件,qt,events,kiosk,childwindow,kiosk-mode,Qt,Events,Kiosk,Childwindow,Kiosk Mode,我正在尝试在几秒钟不活动后自动将鼠标隐藏在应用程序中,并使用下面的代码来处理此问题。在我打开子窗口之前,一切都很好:在我将鼠标移到子窗口上之前,鼠标不会再次出现。如果监视MyMainWindow::eventFilter()中的所有事件,则在子窗口打开时,不会看到父窗口的任何事件。我想qApp->installEventFilter()为应用程序的所有窗口添加了事件过滤器。想法 我的平台是Windows7和Qt4.8。应用程序在一台安装了信息亭的计算机上全屏运行——也就是说,除了我的应用程序之外

我正在尝试在几秒钟不活动后自动将鼠标隐藏在应用程序中,并使用下面的代码来处理此问题。在我打开子窗口之前,一切都很好:在我将鼠标移到子窗口上之前,鼠标不会再次出现。如果监视MyMainWindow::eventFilter()中的所有事件,则在子窗口打开时,不会看到父窗口的任何事件。我想
qApp->installEventFilter()
为应用程序的所有窗口添加了事件过滤器。想法

我的平台是Windows7和Qt4.8。应用程序在一台安装了信息亭的计算机上全屏运行——也就是说,除了我的应用程序之外,计算机上没有其他任何东西在运行

MyMainWindow::MyMainWindow( QWidget *parent ) :
    QMainWindow( parent ),
    ui( new Ui::MyMainWindow )
{
    // all the other setup...
    hideMouseTimer.start( HideMouseDelay_ms );
    connect( &hideMouseTimer, SIGNAL(timeout()), this, SLOT(hideMouseTimerExpiry()) );

    if( qApp )
    {
        qApp->installEventFilter( this );
    }
}

bool MyMainWindow::eventFilter( QObject *obj, QEvent *event )
{
   /*
    * Monitor mouse movement. If the mouse has been hidden, show it and start
    * the timer for the next check for hiding it.
    */
   if( event->type() == QEvent::MouseMove )
   {
       qApp->restoreOverrideCursor();
       hideMouseTimer.start( HideMouseDelay_ms );
   }

   return QWidget::eventFilter( obj, event ); 
}

void MyMainWindow::hideMouseTimerExpiry()
{
    qApp->setOverrideCursor( QCursor( Qt::BlankCursor ) );
    hideMouseTimer.stop();
}

void MyMainWindow::on_dialog_clicked()
{
    myDiaglog *d = new myDialog();
    d->exec();
    delete d;
}

这是完整的密码吗?事件筛选器不返回值。您所指的对话框是“子窗口”吗?@jmk不,它不是完整的代码,而是我认为相关的部分。我将return语句添加到事件过滤器中。是的,子窗口是对话框。