Best way to implement Window menu
-
My program has a Window menu that lists out all of the open windows: each action, when triggered, should raise the selected window and give it keyboard focus. <code>raise()</code> is easy enough, since it's a slot, but it doesn't give the window the input focus. <code>activateWindow()</code> isn't a slot. What is the best way of implementing this behavior? Is there a slot that does this that I'm missing?
-
You could derive your windows from your own subclass. In that you can add a new slot that calls raise() and activateWindow(). The other solution would be to add a slot to your main class and do it there. You need to add some bookkeeping about the windows, though.
-
Sorry, I have no clue, why this is not a slot. You might want to file a suggestion on the "public bugtracker":https://bugreports.qt.nokia.com/. So at least it will be reconsidered for the upcoming Qt 5 release later this year.