PDA

View Full Version : switch a QWidget inside a QMainWindow to fullscreen



koenux
11th January 2009, 20:21
I have a QWidget inside a QMainWindow. When someone pressed the F11 key, the widget have to switch to fullscreen. When the F11 key is pressed again, I want to get that widget back into his normal Window state.

I'm using PyQT:

def toggleFullScreen(self):
if self.parent.ui.videoframe.isFullScreen() :
debug().info("Fullscreen mode: off")
self.parent.ui.videoframe.setWindowState(Qt.Window NoState)
self.parent.ui.videoframe.setWindowFlags(Qt.Widget );
self.parent.ui.show()
else:
debug().info("Fullscreen mode: on")
self.parent.ui.videoframe.setWindowFlags(Qt.Window );
self.parent.ui.videoframe.setWindowState(Qt.Window FullScreen)
self.parent.ui.videoframe.show()

When I set the Qt.Window flag, fullscreen will work. But now the event filter on the MainApplication won't receive QEvents anymore because (I guess) the mainwindow isn't on top.

"self.parent" is the main application class.
"videoframe" is the widget

How can I solve this?

Thanks!

Edit
Of course! I had to install a event filter on the videoframe widget. But I have to keep the eventfilter from the mainapplication because the the videoframe wiget doesn't receive QEvents when it's a normal widget. But now when I press F11 on fullscreen state, the event filter from the main application will also receive that event.

So I've got a new problem.

edit 2
Stupid me, self.parent.ui.show() had to be self.parent.ui.videoframe.show()

This problem is solved

koenux
11th January 2009, 21:25
I have another question. QWidget::setWindowState() will change the winId(). But I don't want to have the QWidget::winId() changed, because I need it for gstreamer.

Is there a way to toggle fullscreen without changing the winId() ?