Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can a single widget be made to go full-screen, without making the whole window fullscreen?
Forum Updated to NodeBB v4.3 + New Features

Can a single widget be made to go full-screen, without making the whole window fullscreen?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 5.9k 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.
  • D Offline
    D Offline
    donquibeats
    wrote on last edited by
    #1

    Hello

    I'm wondering if it's possible to make a single widget temporarily go full-screen in my PyQt5 application, without fullscreening the whole of the window that contains the widget.

    In my tests the answer would appear to be "no" but I was wondering if maybe I'm doing something wrong, or if there's a workaround that might be applicable for this.

    I've pasted some example code below. The form looks like this:
    Qt form showing three widgets

    What I would like is for the 'full-screen test' button to make the button and the "Label on inner layout" go full-screen, but the "Label on outer layout" should NOT be visible- so only the inner layout goes full-screen.

    Can this be done at all, and if so, why is it not working in my code please?

    import sys
    from PyQt5.QtWidgets import QApplication, QDialog, QPushButton, QLabel, QGridLayout, QFrame
    from PyQt5.QtCore import Qt
    
    
    class FullScreenTest(QDialog):
        def __init__(self):
            super().__init__()
            self.setWindowFlags(Qt.WindowCloseButtonHint | Qt.WindowType_Mask)
            self.title = 'PyQt5 tests'
            self.outerLayout = QGridLayout(self)
            self.innerLayout = QGridLayout()
            self.button = QPushButton("Full-screen test")
    
            self.innerLayout.addWidget(self.button, 0, 0)
            self.innerLayout.addWidget(QLabel("Label on inner layout"), 0, 1)
            self.innerLayout_frame = QFrame()
            self.innerLayout_frame.setLayout(self.innerLayout)
            self.outerLayout.addWidget(self.innerLayout_frame, 0, 0)
            self.outerLayout.addWidget(QLabel("Label on outer layout"), 1, 0)
    
            self.button.clicked.connect(lambda: switch_fullscreen(self.innerLayout_frame))
            self.show()
    
    
    def switch_fullscreen(targetWidget):
        if targetWidget.isFullScreen():
            targetWidget.showNormal()
            print("Showing normal.")
        else:
            targetWidget.showFullScreen()
            print("Showing fullscreen.")
    
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        ex = FullScreenTest()
        sys.exit(app.exec_())
    
    
    1 Reply Last reply
    0
    • J Offline
      J Offline
      jumpy88
      wrote on last edited by jumpy88
      #2

      Perhaps this may help, or at least be a starting point
      https://forum.qt.io/topic/23308/how-to-fullscreen-the-child-widget
      or this other too
      https://stackoverflow.com/questions/1246825/fullscreen-widget

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        You have to remove the widget from the layout containing it and then you can make it fullscreen. You will also have to put it back in place once you get out of fullscreen mode.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        D 1 Reply Last reply
        5
        • SGaistS SGaist

          Hi,

          You have to remove the widget from the layout containing it and then you can make it fullscreen. You will also have to put it back in place once you get out of fullscreen mode.

          D Offline
          D Offline
          donquibeats
          wrote on last edited by
          #4

          @SGaist Thanks very much for this explanation. After a bit of fiddling with adjusting fixedWidths and so on, I've now got this working exactly as I was hoping.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Great !

            Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that's other forum users may know a solution has been found :-)

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

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