2

In the debugger, I can see that my QMenu objects do not reside in the same thread as the main gui thread. E.g., QApplication.instance().thread() == 0xdeadbeef, but mymenu.thread() == 0xdeadbabe

1) Is that expected? BTW, my QMenus are not native menus (I used setNativeMenuBar(False))

2) I want to block until the menu is finished processing all events. I tried QApplication.processEvents(), but that's a little tricky because it has to be called from the same thread as the the widget I want to wait for (in my case, the menu). I used a custom event filter class in combination with moveToThread() to make sure that processEvents() is called from the same thread that QMenu is running in, but it doesn't seem to matter.

No matter what I try, I can't seem to block for the completion of all QMenu event/action signal handling. My only option seems to be to sleep() long enough that I know the processing is finished. But that's not really acceptable for my use-case.

Stuart Berg
  • 17,026
  • 12
  • 67
  • 99
  • I don't think the debugger is telling you what you think it is--http://en.wikipedia.org/wiki/Hexspeak – Matt Phillips Apr 03 '13 at 00:29
  • @Matt I think he knows that. He's not saying that the debugger is telling him the *actual* locations are `0xdeadbeef` and `0xdeadbabe`, those are just examples to demonstrate that they are indeed located at two different memory addresses. – Cody Gray - on strike Apr 03 '13 at 05:02
  • @CodyGray Hmmm, seems like an odd way to go about describing the situation, presumably OP will step in and clear it up. – Matt Phillips Apr 03 '13 at 05:12
  • Sorry for the confusion. CodyGray is correct. I was merely trying to show that the two threads are not the same by showing that they are at different addresses. The addresses I gave are not the ones that appeared in the debugger. – Stuart Berg Apr 03 '13 at 06:58
  • 1
    maybe you should instead check where menus are created so that they are in the main thread from the beginning – spiritwolfform Apr 03 '13 at 08:55
  • I tried : `info("% %u", QApplication::instance()->thread(), menuBar()->thread());` and it returned twice the – galinette Sep 12 '13 at 10:32

0 Answers0