How to Fullscreen the child widget
-
How to Fullscreen the child widget
The UI is as following
http://img.my.csdn.net/uploads/201212/06/1354779576_2592.jpgWhat I want to do is that
When doubleclick the black widget ,it should become in full screen mode ,then if I doubleclick again ,it should return back .
So how to ?showFullScreen()only affects windows
but when I setWindowFlags(Qt.Window) of that black widget ,the UI becomes like this
http://img.my.csdn.net/uploads/201212/06/1354779928_2090.jpg
so how can I implement this functionality ?
BTW ,Phonon.VideoWidget Inherits QWidget and it has setFullScreen() method ,who know how it is implemented ?
-
This is just a layout issue, should not be related with the setFullScreen() implementation.
You just need to add a QGridLayout in the main window, and use the grid as the main container. -
The following is a basic working example of what I think you're trying to do. It also hides the lower controls (sliders and buttons) in full screen mode like a media player would (just delete line 55 to prevent this):
@
from PyQt4.QtCore import *
from PyQt4.QtGui import *class BlackWidget(QWidget):
doubleClick=pyqtSignal() def __init__(self, parent=None, **kwargs): QWidget.__init__(self, parent, **kwargs) def paintEvent(self, e): p=QPainter(self) p.fillRect(self.rect(), Qt.black) def mouseDoubleClickEvent(self, e): self.doubleClick.emit()
class Widget(QWidget):
def init(self, parent=None):
QWidget.init(self, parent)self.resize(640,480) self._fullScreen=False l=QGridLayout(self) blackWidget=BlackWidget(self, doubleClick=self.changeScreenSize) l.addWidget(blackWidget, 0, 0, 1, 4) self._controls=[] slider1=QSlider(Qt.Horizontal, self) self._controls.append(slider1) l.addWidget(slider1, 1, 0, 1, 4) button1=QPushButton("Button 1", self) self._controls.append(button1) l.addWidget(button1, 2, 0) button2=QPushButton("Button 2", self) self._controls.append(button2) l.addWidget(button2, 2, 1) button3=QPushButton("Button 3", self) self._controls.append(button3) l.addWidget(button3, 2, 2) slider2=QSlider(Qt.Horizontal, self) self._controls.append(slider2) l.addWidget(slider2, 2, 3) @pyqtSlot() def changeScreenSize(self): self.showNormal() if self._fullScreen else self.showFullScreen() for c in self._controls: c.setVisible(self._fullScreen) self._fullScreen^=True
if name=="main":
from sys import argv, exit
a=QApplication(argv)
w=Widget()
w.show()
w.raise_()
exit(a.exec_())
@Hope this helps ;o)