Results 1 to 12 of 12

Thread: QVideoWidget Fullscreen

  1. #1
    Join Date
    Jul 2014
    Posts
    46
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default QVideoWidget Fullscreen

    I want to make my QVideoWidget fullscreen on mouse click and back.
    I've implemented the mouse click and have tried two methods to go fullscreen but both are not working.

    Method 1:
    Qt Code:
    1. w->setWindowState(w->windowState() ^ Qt::WindowFullScreen);
    To copy to clipboard, switch view to plain text mode 
    And to come back
    Qt Code:
    1. w->setWindowState(w->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
    To copy to clipboard, switch view to plain text mode 

    Nothing happens in this case.

    Method 2: (found after some good internet searching)
    Qt Code:
    1. void mousePressEvent(QMouseEvent*) {
    2. if (maxMode== false)
    3. {
    4. m_enOrigWindowFlags = this->windowFlags();
    5. m_pSize = this->size();
    6. this->setParent(0);
    7. this->setWindowFlags( Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
    8. this->showFullScreen();
    9. maxMode = true;
    10. }
    11. else
    12. {
    13. this->setParent(m_pParent);
    14. this ->resize(m_pSize);
    15. this->overrideWindowFlags(m_enOrigWindowFlags);
    16. this->show();
    17. maxMode = false;
    18. }
    19. }
    20. };
    To copy to clipboard, switch view to plain text mode 
    This method works fine to get to fullscreen. But on the second click the video widget comes in a new window and not on the original position on the Ui.

    Please help me. Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QVideoWidget Fullscreen

    QWidget::showNormal()
    Qt Code:
    1. void mousePressEvent(QMouseEvent*) {
    2. maxMode = !maxMode;
    3. if(maxMode) showFullscreen(); else showNormal();
    4. };
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2014
    Posts
    46
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QVideoWidget Fullscreen

    Nothing happens Sir.
    No change in the widget!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QVideoWidget Fullscreen

    What exactly did you change? What does the code currently look like?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jul 2014
    Posts
    46
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QVideoWidget Fullscreen

    this is my .h file

    Qt Code:
    1. #ifndef MYTCPSOCKET_H
    2. #define MYTCPSOCKET_H
    3.  
    4. #include <QMainWindow>
    5. #include <QTcpSocket>
    6. #include <QUdpSocket>
    7. #include <QAbstractSocket>
    8. #include <QProcess>
    9. #include <QDebug>
    10. #include <QMediaPlayer>
    11. #include <QVideoWidget>
    12. #include <QProcess>
    13.  
    14. namespace Ui {
    15. class MyTcpSocket;
    16. class ClickableVideo;
    17. }
    18.  
    19. class ClickableVideo : public QVideoWidget
    20. {
    21. Q_OBJECT
    22. public:
    23. ClickableVideo(QWidget *parent = 0) : QVideoWidget(parent) {
    24. m_pParent = parent;
    25. maxMode = false;
    26. maxMode1 = false;
    27. maxMode2 = false;
    28. maxMode3 = false;
    29. connect(this, SIGNAL(clicked()), this, SLOT(slotClicked()));
    30. }
    31. QWidget* m_pParent;
    32. bool maxMode,maxMode1,maxMode2,maxMode3;
    33. Qt::WindowFlags m_enOrigWindowFlags;
    34. QSize m_pSize;
    35.  
    36. signals:
    37. void clicked(void);
    38. void reconnect(void);
    39.  
    40. public slots:
    41. void slotClicked();
    42.  
    43. protected:
    44. void mouseReleaseEvent(QMouseEvent* event) // or double clicked or what you want
    45. {
    46. emit this->clicked();
    47. }
    48.  
    49. private:
    50. Ui::ClickableVideo *ui;
    51. };
    52.  
    53. class MyTcpSocket : public QMainWindow
    54. {
    55. Q_OBJECT
    56.  
    57. public:
    58. explicit MyTcpSocket(QWidget *parent = 0);
    59. ~MyTcpSocket();
    60. void doConnect();
    61. void session_splitter(QByteArray &received_data);
    62. void rtp_to_frame_splitter(QByteArray &received_data);
    63.  
    64. private:
    65. Ui::MyTcpSocket *ui;
    66.  
    67. signals:
    68. public slots:
    69. void connected();
    70. void disconnected();
    71. void reconnect_widget();
    72. void bytesWritten(qint64 bytes);
    73. void readyRead();
    74. void on_pushButton_clicked();
    75. void on_pushButton_4_clicked();
    76.  
    77. private:
    78. QProcess *mInputPlayProcess;
    79. QTcpSocket *socket;
    80. QTcpSocket *send_socket;
    81. QMediaPlayer *player1;
    82. QMediaPlayer *player2;
    83. QMediaPlayer *player3;
    84. QMediaPlayer *player4;
    85. ClickableVideo *videoWidget1;
    86. ClickableVideo *videoWidget2;
    87. ClickableVideo *videoWidget3;
    88. ClickableVideo *videoWidget4;
    89. };
    90.  
    91. #endif // MYTCPSOCKET_H
    To copy to clipboard, switch view to plain text mode 

    In my mytcpsocket.cpp file I have implemented the slot like this
    Qt Code:
    1. void ClickableVideo::slotClicked()
    2. {
    3. //QObject *pobj;
    4. //pobj = this->sender();
    5. //QString str = pobj->objectName();
    6. //if(str == "videoWidget1")
    7. //{
    8. if (maxMode== false)
    9. {
    10. //this->setParent(0);
    11. this->showFullScreen();
    12. maxMode = true;
    13. }
    14. else
    15. {
    16. emit this->reconnect();
    17. this->showNormal();
    18. maxMode = false;
    19. }
    20. //}
    21. }
    To copy to clipboard, switch view to plain text mode 

    Two additional things I want to ask:
    The objectname doesn't give me a name because videowidget is not part of the Ui file. So how can I seperate out between various widgets.
    And if I uncomment setparent(0) it goes to fullscreen but as it was happening earlier comes back to normal size in another window!
    Please Help!


    Added after 47 minutes:


    Also why isn't this connection working?
    connect(videowidget1,SIGNAL(reconnect()),this,SLOT (reconnect_widget()));
    This has been done in the constructor of mytcpsocket but it isn't going to the slot on emitting the signal? Why?
    Last edited by antweb; 27th May 2015 at 13:33.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QVideoWidget Fullscreen

    Quote Originally Posted by antweb View Post
    And if I uncomment setparent(0) it goes to fullscreen but as it was happening earlier comes back to normal size in another window!
    Restore the parent to the original value when returning from full screen.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jul 2014
    Posts
    46
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QVideoWidget Fullscreen

    I did that as well as you can see in my original post. It still opens in another window!

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QVideoWidget Fullscreen

    Quote Originally Posted by antweb View Post
    I did that as well as you can see in my original post. It still opens in another window!
    No, that's not possible. Are you sure m_pParent is initialized properly?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jul 2014
    Posts
    46
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QVideoWidget Fullscreen

    Yes, I'm getting no value in the parent.
    If I'm placing my video widget in a horizontal layout so will that be the parent?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QVideoWidget Fullscreen

    Quote Originally Posted by antweb View Post
    Yes, I'm getting no value in the parent.
    What does that mean?

    If I'm placing my video widget in a horizontal layout so will that be the parent?
    No, layouts are not parents of a widget. If you really have to do manipulations like that then store a pointer to the parent just before you call setParent(0). However in my opinion it is better to hide all siblings of the player but the player itself and then show its window in full screen. When going back from full screen, show back the widgets you hid earlier.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Jul 2014
    Posts
    46
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QVideoWidget Fullscreen

    Okay, so I set the parent correctly, but in this case when I come back from my full screen my widget is blank although on clicking again it goes to fullscreen but on coming back it goes black.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QVideoWidget Fullscreen

    So is it blank or black?

    What about the approach I suggested?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QVideoWidget on macos blocks application, need help.
    By DavidXanatos in forum Qt Programming
    Replies: 3
    Last Post: 11th July 2016, 20:19
  2. QVideoWidget , QMediaPlayer : missing video frames
    By vee_sivee in forum Qt Programming
    Replies: 0
    Last Post: 27th April 2015, 05:11
  3. Replies: 0
    Last Post: 15th March 2014, 02:19
  4. Replies: 3
    Last Post: 12th July 2011, 23:55
  5. Replies: 0
    Last Post: 8th April 2010, 12:08

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.