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. Best practice for making a video widget fullscreen
QtWS25 Last Chance

Best practice for making a video widget fullscreen

Scheduled Pinned Locked Moved Unsolved General and Desktop
fullscreenvideo
6 Posts 2 Posters 4.6k Views
  • 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.
  • J Offline
    J Offline
    JordanHarris
    wrote on 2 Feb 2016, 06:41 last edited by
    #1

    What is the best way to make a child widget (video widget) fullscreen? I have a video widget (from VLC-Qt) as a child widget in my application. I've created the GUI so far using Qt Designer and everything is currently in a grid layout.

    I can detach the child widget by setting the parent to nullptr and calling showFullScreen() on the widget to make it full screen. That works pretty well, but I have no idea how I can make the widget go back to its original location once I exit fullscreen mode since I'm using a grid layout.

    I'm probably going about this the wrong way and probably shouldn't use a grid layout anyways, but the grid layout has worked out well so far. Perhaps it would be easier if I used another layout system. Anyways, does anyone have an idea of what I can do here? I noticed that the Qt media player has fullscreen functionality built in, but I'm not sure how that works. I would really appreciate any help or feedback about this. This is my first time trying to create a media player.

    R 1 Reply Last reply 2 Feb 2016, 07:09
    0
    • J JordanHarris
      2 Feb 2016, 06:41

      What is the best way to make a child widget (video widget) fullscreen? I have a video widget (from VLC-Qt) as a child widget in my application. I've created the GUI so far using Qt Designer and everything is currently in a grid layout.

      I can detach the child widget by setting the parent to nullptr and calling showFullScreen() on the widget to make it full screen. That works pretty well, but I have no idea how I can make the widget go back to its original location once I exit fullscreen mode since I'm using a grid layout.

      I'm probably going about this the wrong way and probably shouldn't use a grid layout anyways, but the grid layout has worked out well so far. Perhaps it would be easier if I used another layout system. Anyways, does anyone have an idea of what I can do here? I noticed that the Qt media player has fullscreen functionality built in, but I'm not sure how that works. I would really appreciate any help or feedback about this. This is my first time trying to create a media player.

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 2 Feb 2016, 07:09 last edited by
      #2

      @JordanHarris said:

      I can detach the child widget by setting the parent to nullptr and calling showFullScreen() on the widget to make it full screen.

      Just a small hint: You do not need to detach the widget by setting the parent to null. Instead use QWidget::setParent( parent, Qt::Tool )

      That works pretty well, but I have no idea how I can make the widget go back to its original location once I exit fullscreen mode since I'm using a grid layout.

      Why can't you simply read it to the layout? The same way you inserted it in the first place?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JordanHarris
        wrote on 2 Feb 2016, 09:21 last edited by JordanHarris 2 Feb 2016, 09:23
        #3

        @raven-worx said:

        Just a small hint: You do not need to detach the widget by setting the parent to null. Instead use QWidget::setParent( parent, Qt::Tool )

        Ahh thank you for that tip. I ended up doing that, but how do you make it go back to a normal widget? I used setParent(parent, Qt::Subwindow) and it worked, but I'm not sure if that's the best way.

        Why can't you simply read it to the layout? The same way you inserted it in the first place?

        So I went to the generated UI file to see how it was adding the video widget to the grid layout and used that same code to add it back to the layout. It works perfectly now. :) Thank you very much for your help. I probably should've thought of that myself, but anyways I really appreciate the help.

        I should probably figure out a better layout system than just using the grid layout because I suspect that I'll have to change the code that adds the video widget back whenever I add something to the UI. I'll have to experiment with that when I can.

        R 1 Reply Last reply 2 Feb 2016, 09:26
        0
        • J JordanHarris
          2 Feb 2016, 09:21

          @raven-worx said:

          Just a small hint: You do not need to detach the widget by setting the parent to null. Instead use QWidget::setParent( parent, Qt::Tool )

          Ahh thank you for that tip. I ended up doing that, but how do you make it go back to a normal widget? I used setParent(parent, Qt::Subwindow) and it worked, but I'm not sure if that's the best way.

          Why can't you simply read it to the layout? The same way you inserted it in the first place?

          So I went to the generated UI file to see how it was adding the video widget to the grid layout and used that same code to add it back to the layout. It works perfectly now. :) Thank you very much for your help. I probably should've thought of that myself, but anyways I really appreciate the help.

          I should probably figure out a better layout system than just using the grid layout because I suspect that I'll have to change the code that adds the video widget back whenever I add something to the UI. I'll have to experiment with that when I can.

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 2 Feb 2016, 09:26 last edited by raven-worx 2 Feb 2016, 09:27
          #4

          @JordanHarris
          ah sorry have overread that you were using QtDesigner.

          I am not sure if you should really use Qt::SubWindow flag. Normally this is only used by QMdiSubWindow? The suggested Qt::Tool of mine was already appropriate.
          Qt::Tool is a separate window which doesn't show up in the taskbar.
          Probably even better would be to use

          setParent( parent, Qt:Tool | Qt::CustomizeWindowHint | Qt::FramelessWindowHint );
          

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JordanHarris
            wrote on 2 Feb 2016, 10:36 last edited by
            #5

            Thank you for that suggestion. I'm going to try that as soon as I can. Yeah I shouldn't have at it to Qt::SubWindow. I should just set it back to Qt::Widget, which is the default. Also, I probably don't even need to be using the setParent() function. I could probably just use setWindowFlags() and be alright. Thanks for ask the help man. Just discussing this has made things clearer to me. I probably would've done something crazy to get full screen functionality if I didn't post this. It's working quite well now, even without those few changes mentioned earlier.

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JordanHarris
              wrote on 15 Feb 2016, 14:21 last edited by JordanHarris
              #6

              Just an update: I ended up just using a "container widget" that holds the video widget. This way I can just add the container widget to the layout and detach the video widget from the container when going full screen. Then I just add it back to the container instead of trying to add it to the layout exactly as it was. In my case, I'm actually using a QStackedWidget as the "container" since I need to switch the video out with other views anyways. It works out perfectly. This project is really coming along nicely. I'm loving Qt right now. :)

              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