PDA

View Full Version : Keyboard shortcuts in full screen mode



dfijma
29th November 2010, 11:55
My application (based on Qt 4.7) supports full screen mode. What I would like to accomplish is to hide all UI elements so that I can use the screen for a "clean" full screen display of video. At the same time, I would like to keep the main menu shortcut keys operational.

After switching to full screen using QWidget::showFullScreen(), I use ui->menuBar->hide() to hide (amongst others) the main menu. When I run this program under Mac OSX, it works. The menu is no longer displayed, but keyboard shortcuts (like "Command-R" to restart a video stream) keep working.

Under Windows, however, shortcut keys do not seem to be working while the menu is hidden.

As an experiment, I tried setting up "manual" QAction objects in my mainwindow, something like:

reconnectAction = new QAction(this);
reconnectAction->setShortcuts(tr("Ctrl+R");
connect(reconnectAction, SIGNAL(triggered()), this, SLOT(reconnect()));

but a (shortcut to a) QAction does not seem to work while the QAction is not added to some menu. But the catch is that there is no menu while in full screen mode.

Is there an (official) way to implement keyboard shortcuts in full screen mode (e.g., without a displayed menu).

Thanks,

--
Duco

bothorsen
29th November 2010, 13:09
There is a very simple solution to this: Just add the actions to your main window.

The problem is that when an action is only added to widgets that are hidden or disabled, those actions become disabled as well. So by adding your actions to the main window, they are not disabled, and the shortcuts work.