Results 1 to 3 of 3

Thread: how to attach the video player window into my Mainwidow

  1. #1
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default how to attach the video player window into my Mainwidow

    Hi,

    the following code creates a video player object and shows mp4 video in a seperate window. Though, this is not exactly what i want.
    I need to create a movie widget inside the main window, should be located in the middle, with some buttons n slider added to the other sides of it.

    As, I am new to Qt graphics, I don't know what to add to this code.
    would anyone help me revising the code please.

    Yours

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. #include <phonon/MediaObject>
    5. #include <phonon/VideoPlayer>
    6.  
    7. MainWindow::MainWindow(QWidget *parent) :
    8. QMainWindow(parent),
    9. ui(new Ui::MainWindow)
    10. {
    11. ui->setupUi(this);
    12.  
    13. Phonon::MediaObject *media;
    14.  
    15. media = new Phonon::MediaObject();
    16. media->setCurrentSource(Phonon::MediaSource(QString("/home/saman/4.7/phonon_test/sample.mp4")));
    17.  
    18. Phonon::VideoPlayer *videoPlayer;
    19.  
    20. videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory);
    21. videoPlayer->setFixedSize(QSize(400, 300));
    22. videoPlayer->move(1280-400, 0);
    23. videoPlayer->show();
    24.  
    25. connect(videoPlayer, SIGNAL(finished()), videoPlayer, SLOT(deleteLater()));
    26. videoPlayer->play(media->currentSource());
    27. }
    28.  
    29. MainWindow::~MainWindow()
    30. {
    31. delete ui;
    32. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to attach the video player window into my Mainwidow

    make the widget the mainwindow's central widget
    http://qt-project.org/doc/qt-5.0/qma...tCentralWidget

    If you are going to be working with Qt for a while then you will need to learn the basics and get familiar with the manual ^^, rather than always ask others to re-write code for you. There are lots of tutorials and examples around.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: how to attach the video player window into my Mainwidow

    make the widget the mainwindow's central widget
    not good, if you want additional widgets on the sides.

    Learn the concept of parenting.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. frame and video player
    By Kethan Kumar in forum Qt Programming
    Replies: 0
    Last Post: 17th February 2012, 09:38
  2. wildcards with phonon video player
    By prophet0 in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2012, 12:55
  3. how to set duration of a video in a video player in qt
    By qt_user in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2010, 10:51
  4. Phonon Video Player Problem...
    By emrez in forum Qt Programming
    Replies: 0
    Last Post: 14th July 2010, 14:26
  5. Phonon Video Player + XML
    By igor.schkrab in forum Qt Programming
    Replies: 0
    Last Post: 24th November 2009, 23:49

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
  •  
Qt is a trademark of The Qt Company.