Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. How to Fullscreen the child widget
Forum Updated to NodeBB v4.3 + New Features

How to Fullscreen the child widget

Scheduled Pinned Locked Moved Language Bindings
3 Posts 3 Posters 6.3k Views 1 Watching
  • 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 Offline
    R Offline
    redstoneleo
    wrote on 6 Dec 2012, 07:56 last edited by
    #1

    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
    0
    • D Offline
      D Offline
      danut.iurascu
      wrote on 6 Dec 2012, 09:19 last edited by
      #2

      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
      0
      • J Offline
        J Offline
        jazzycamel
        wrote on 6 Dec 2012, 09:25 last edited by
        #3

        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
        0

        1/3

        6 Dec 2012, 07:56

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved