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. Qt Mac OSX: Few menu items are disabled after QFileDialog
Forum Updated to NodeBB v4.3 + New Features

Qt Mac OSX: Few menu items are disabled after QFileDialog

Scheduled Pinned Locked Moved General and Desktop
macosx
4 Posts 2 Posters 1.7k 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.
  • M Offline
    M Offline
    msms
    wrote on last edited by
    #1

    Hello. Sorry if this is not the right place to post this. I am not sure if this is a bug.

    I use QFileDialog static functions (getOpenFile and getSaveFile) in my Qt app. It works perfectly on Linux and Windows.

    On Mac however, after running the dialog, the menu items Cut, Copy, Paste and Select All are disabled. Putting in setEnabled(true) on the actions after QFileDialog returns didn't work, the menu items stay disabled. I also tried menuBar()->update() with no success.

    The one thing that does help is DontUseNativeDialogs. When I use it, the menu items are unaffected after. Still, I would like to use native dialogs on Mac (the non-native dialogs look very out of place).

    Important to point out that the same QFileDialog works fine on Linux and Windows and doesn't mess up the menu. I've tried Qt 5.4.0 and 5.4.1 on Mac and both have this problem.

    Could this be a bug? I would be surprised that I discovered it, considering that it seems like something that would be noticed right away. As such, I put it as more likely that it's something wrong that I am doing. Any ideas? I am looking for any solutions. If I become desperate, I will try to regenerate the entire menu bar after using QFileDialog (but this shouldn't be necessary!).

    BTW, I found an old bug, QTBUG-20156, but it seems like that affects Mac OSX 10.4. My problems are occurring on 10.8 and 10.10 (latest, Yosemite).

    Thanks!

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

      Hi,

      Since you seem to hit a similar bug, would you consider opening a new report providing a minimal compilable example that reproduce the behavior ? Linking to the old one would also be good.

      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
      1
      • M Offline
        M Offline
        msms
        wrote on last edited by
        #3

        I wasn't able to create a minimal example. When I set up a trivial window with a menu and add a Copy action, it doesn't disable when I open a QFileDialog.

        I tried to be careful and do it in the same way like in my app, but of course it could be any number of things (it is an app with a 50 or so menu items, and a number of widgets and I have seen enough odd bugs in my life to know that anything can trigger a bug, especially my stupidity or say, gamma rays).

        I did have success with a small discovery! If I call setMenuRole(QAction::NoRole) on my "Copy", "Paste", "Cut" and "Select All", then they won't disable after calling QFileDialog. Unfortunately, in this case the "Copy", "Paste", "Cut" and "Select All" actions don't work in the file dialog, but this is much preferred over them not working in the app.

        I understand that Qt does a lot of magic with menus on the Mac (considering how they work with the global menu and everything), so this may be a useful pointer at the source of the problem. Perhaps I will look into Qt Mac source (if it is not too hard to get into it).

        In the meantime, if anyone else runs across this, please post any information you discover.

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

          Speaking of gamma rays, you could try to take a look at your application with KDAB's Gamma Ray you might find with it if you have some funny signal/slot/even loop stuff going on.

          The cocoa platform plugin would be the place to start digging if you want to get the gory details.

          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

          • Login

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