How can I disable sounds played by Qt QMessageBox?
qt, windows
Solution
If you use a different `QMessageBox`, `QMessageBox::about`, or make your own instance of `QMessageBox` and set the `iconPixmap` and everything yourself, you shouldn't get the beeping noise.
QMessageBox::warning(0, "Test", "test"); // Plays alert
QMessageBox::about(0, "Test", "test"); // No sound, but no icon either
QMessageBox msgBox;
msgBox.setParent(0);
msgBox.setWindowTitle("Test");
msgBox.setText("test");
if(false)
{
msgBox.setIcon(QMessageBox::Warning);// makes sound
}
else
{
QPixmap p;
p.load("warning.png");
msgBox.setIconPixmap(p);// no sound, but with icon
}
msgBox.exec();
Otherwise, to disable the warning sound, you probably will need a global event filter on your app to catch any event/message from `QAccessibility` with the role of `QAccessible::AlertMessage`.
Hope that helps.
Problem
I am working on a Windows application using Qt 4.8 that uses ``` QMessageBox::information QMessageBox::warning ... ``` When any of thes functions is called, windows plays by default a sound. My customers are annoyed of this and want to disable this permanently without changing windows settings. How can I get rid if this sound? I found that it is called from ``` void QAccessible::updateAccessibility() ``` But I do not so far see a way to disable it.