Unsolved How to disable QMenu fade?
-
A QMenu will fade out when it’s closed and I’d rather it didn’t. I tried inserting this call in various places...
QApplication::setEffectEnabled(Qt::UI_FadeMenu, false);
but that had no effect. I tried disabling all of the effects and also doing this...
QApplication::setDesktopSettingsAware(false);
but still nothing happened. Everything I’ve tried has had no effect on the end result. I’m not sure what else to do.
-
Hi,
You have to give more details:
- What version of Qt ?
- What OS ?
Can you provide a minimal compilable example that shows that behaviour ?
-
@SGaist I'm using Qt 5.12.3 (5.13 doesn't seem to be available on Homebrew yet) and macOS 10.14.5. Here's an example:
#include <QtWidgets/qmenubar.h> #include <QtWidgets/qmainwindow.h> #include <QtWidgets/qapplication.h> void disable() { QApplication::setDesktopSettingsAware(false); QApplication::setEffectEnabled(Qt::UI_FadeMenu, false); } int main(int argc, char **argv) { disable(); QApplication app{argc, argv}; disable(); QMainWindow window; disable(); QMenuBar menubar{&window}; disable(); menubar.setNativeMenuBar(false); QMenu *file = menubar.addMenu("File"); file->setStyleSheet("border: none; outline: none"); disable(); file->addAction("Open"); file->addAction("Save"); window.show(); disable(); return app.exec(); }
Along with the fade, there's also this really annoying black border that I can't seem to remove with stylesheets. The above stylesheet just removes the rounded corners. When I add my own border, the black border appears around my own border. Removing the border is probably more important to me than the fade. The border also appears around tooltips.