Action on a video while in FullScreen
-
Hi.
I try to develop a little video player with Qt by using QMediaPlayer and QVideoWidget (amongst other).
One of the feature is to be capable of playing and pausing the video by using the spacebar Key. It works very well into the main window but when I set the Video Widget to be fullscreen by double clicking it, the spacebar shortcut doesn't work.The spacebar event implementation is generated into my MainWindow (inherits of QMainWindow) class while videowidget's fullscreen settings are handled into my VideoWidget class which inherits of QVideoWidget.
Is there any way to set the action of the QMediaPlayer to the fullscreen video widget ?
-
When in fullscreen mode, QVideoWidget is a separate window, not a child widget of your MainWindow, so the key events won't be passed to the MainWindow.
You can:- Also add spacebar event implementation to your VideoWidget class.
- If you don't have other window in your application, then instead of handling key event, you can use QAction / QShortcut with ApplicationShortcut context.
-
That's what I thought.
In the end, I've added the spacebar event implementation like you said but it's kind of dirty since the builder of VideoWidget now call a QMediaPlayer object within it to handle the play/pause signals.
It works, but I don't like this architecture. So I'll try to regroup all the functionality of the VideoWidget (reading and rendering) within a widget that I'll add to the main window.Anyway, thanks for your answer !