Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to disable QMenu fade?
Forum Updated to NodeBB v4.3 + New Features

How to disable QMenu fade?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 641 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kerndog73
    wrote on last edited by Kerndog73
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You have to give more details:

      • What version of Qt ?
      • What OS ?

      Can you provide a minimal compilable example that shows that behaviour ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kerndog73
        wrote on last edited by Kerndog73
        #3

        @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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved