{
if(e
->type
() == QEvent::KeyPress) {
music->play();
music->seek(0);
}
return ui->textEdit->eventFilter(o, e);
}
bool MainWindow::eventFilter(QObject *o, QEvent *e)
{
if(e->type() == QEvent::KeyPress)
{
music->play();
music->seek(0);
}
return ui->textEdit->eventFilter(o, e);
}
To copy to clipboard, switch view to plain text mode
I think the problem is that you are preventing the MainWindow from handling events as it should. Look at the example in QObject::eventFilter(). You want something like that:
{
if(e
->type
() == QEvent::KeyPress) {
music->play();
music->seek(0);
}
}
bool MainWindow::eventFilter(QObject *o, QEvent *e)
{
if(e->type() == QEvent::KeyPress)
{
music->play();
music->seek(0);
}
return QMainWindow::eventFilter( 0, e );
}
To copy to clipboard, switch view to plain text mode
Playing a note every time the user presses a key anywhere in your app might get pretty annoying after a while, don't you think? You sure you don't want to restrict this to specific widgets within your app (like the text edit, for example)?
Bookmarks