Results 1 to 2 of 2

Thread: switch a QWidget inside a QMainWindow to fullscreen

  1. #1
    Join Date
    Jan 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default switch a QWidget inside a QMainWindow to fullscreen

    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:
    Qt Code:
    1. def toggleFullScreen(self):
    2. if self.parent.ui.videoframe.isFullScreen() :
    3. debug().info("Fullscreen mode: off")
    4. self.parent.ui.videoframe.setWindowState(Qt.WindowNoState)
    5. self.parent.ui.videoframe.setWindowFlags(Qt.Widget);
    6. self.parent.ui.show()
    7. else:
    8. debug().info("Fullscreen mode: on")
    9. self.parent.ui.videoframe.setWindowFlags(Qt.Window);
    10. self.parent.ui.videoframe.setWindowState(Qt.WindowFullScreen)
    11. self.parent.ui.videoframe.show()
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by koenux; 11th January 2009 at 21:21. Reason: updated contents

  2. #2
    Join Date
    Jan 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: switch a QWidget inside a QMainWindow to fullscreen

    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() ?

Similar Threads

  1. QScrollArea problem positioning a QWidget inside
    By Spectator in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2006, 22:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.