Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How to Fullscreen the child widget

    Language Bindings
    3
    3
    5881
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      redstoneleo last edited by

      How to Fullscreen the child widget

      The UI is as following
      http://img.my.csdn.net/uploads/201212/06/1354779576_2592.jpg

      What 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 ?

      1 Reply Last reply Reply Quote 0
      • D
        danut.iurascu last edited by

        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.

        regards,
        Dănuț

        1 Reply Last reply Reply Quote 0
        • jazzycamel
          jazzycamel last edited by

          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)

          For the avoidance of doubt:

          1. All my code samples (C++ or Python) are tested before posting
          2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
          1 Reply Last reply Reply Quote 0
          • First post
            Last post