Results 1 to 5 of 5

Thread: how to show video output on a round label not a rectangular one?

  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 show video output on a round label not a rectangular one?

    I have created a QLabel and play a video inside this QLabel in QT using phonon.(videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, movieLabel) Now, As you know the shape of this QLabel is rectangular. I want this QLabel to get a form of a Circle. So, that the video is played inside a circle rather than having rectangular shape.

    this is the showing movie part:
    Qt Code:
    1. void VideoPlayer::startMovieSlot()
    2. {
    3. Phonon::MediaObject *media;
    4. Phonon::VideoPlayer *videoPlayer;
    5.  
    6. media = new Phonon::MediaObject();
    7. media->setCurrentSource(Phonon::MediaSource(QString("./sample.mpg4")));
    8.  
    9. videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, movieLabel);
    10. // videoPlayer->setFixedSize(QSize(400, 300));
    11. videoPlayer->setFixedSize(800, 500);
    12. // videoPlayer->move(1280-400, 0);
    13.  
    14. videoPlayer->show();
    15.  
    16. connect(videoPlayer, SIGNAL(finished()), videoPlayer, SLOT(deleteLater()));
    17. videoPlayer->play(media->currentSource());
    18. }
    To copy to clipboard, switch view to plain text mode 

    Now, I want to create the video QLabel and put the output in a round label not a rectangular one, I have drawn a png circle for that to set it on the video:

    Qt Code:
    1. VideoPlayer::VideoPlayer(QWidget *parent)
    2. : QWidget(parent)
    3. {
    4. // movie = new QMovie(this);
    5. // movie->setCacheMode(QMovie::CacheAll);
    6.  
    7. qDebug() << "VideoPlayer";
    8.  
    9. movieLabel = new QLabel(tr("No movie loaded"));
    10. movieLabel->setAlignment(Qt::AlignCenter);
    11. movieLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    12. movieLabel->setMaximumSize(800, 500);
    13.  
    14. movieLabel->setBackgroundRole(QPalette::Dark);
    15. movieLabel->setAutoFillBackground(true);
    16.  
    17. circle = new QPixmap("./circle.png");
    18. imageBox = new QLabel;
    19. imageBox->setPixmap(*circle);
    20.  
    21. // currentMovieDirectory = "movies";
    22.  
    23. // startMovieSlot();
    24.  
    25. // createControls();
    26.  
    27. createButtons();
    28.  
    29. // connect(movie, SIGNAL(frameChanged(int)), this, SLOT(updateFrameSlider()));
    30. // connect(movie, SIGNAL(stateChanged(QMovie::MovieState)),
    31. // this, SLOT(updateButtons()));
    32. // connect(fitCheckBox, SIGNAL(clicked()), this, SLOT(fitToWindow()));
    33. // connect(frameSlider, SIGNAL(valueChanged(int)), this, SLOT(goToFrame(int)));
    34. // connect(speedSpinBox, SIGNAL(valueChanged(int)),
    35. // movie, SLOT(setSpeed(int)));
    36.  
    37. mainLayout = new QVBoxLayout;
    38. mainLayout->addWidget(movieLabel);
    39. mainLayout->addWidget(imageBox);
    40. // mainLayout->addLayout(controlsLayout);
    41. mainLayout->addLayout(buttonsLayout);
    42. setLayout(mainLayout);
    43.  
    44. // updateFrameSlider();
    45. // updateButtons();
    46.  
    47. setWindowTitle(tr("Movie Player"));
    48. // resize(400, 400);
    49. resize(1024, 786);
    50. }
    To copy to clipboard, switch view to plain text mode 

    my way to solve this problem was this:
    Qt Code:
    1. circle = new QPixmap("./circle.png");
    2. imageBox = new QLabel;
    3. imageBox->setPixmap(*circle);
    To copy to clipboard, switch view to plain text mode 
    but this method doesn't work, moreover the program finishes unexpectedly when I add:
    Qt Code:
    1. mainLayout->addWidget(imageBox);
    To copy to clipboard, switch view to plain text mode 

    any idea how I can show the video output in a circle rather a rectangle?

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

    Default Re: how to show video output on a round label not a rectangular one?

    Don't use Phonon but rather QtMultimedia module.
    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
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: how to show video output on a round label not a rectangular one?

    This is not the answer to my question. If you have any claims, please clarify it.
    Moreover, anyone could tell me how to mask the circle on the video rectangular output?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how to show video output on a round label not a rectangular one?

    Did you search in the docs for the word "mask"?

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

    Default Re: how to show video output on a round label not a rectangular one?

    Quote Originally Posted by saman_artorious View Post
    This is not the answer to my question.
    Ok, here you go --- "You can't show video output on a round label, videos are not shown on labels but rather using a dedicated widget."

    Now go and read about QtMultimedia and implement your own RoundVideoPlayer.
    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.


  6. The following user says thank you to wysota for this useful post:

    saman_artorious (13th July 2012)

Similar Threads

  1. Threading for a video output window?
    By DivideByZer0 in forum Newbie
    Replies: 7
    Last Post: 3rd February 2012, 23:59
  2. QT doesnot show any application output
    By Arpitgarg in forum Newbie
    Replies: 3
    Last Post: 27th March 2011, 12:45
  3. Replies: 0
    Last Post: 17th March 2011, 19:38
  4. Replies: 1
    Last Post: 14th July 2010, 16:34
  5. Phonon Video + Transparent Label Problems
    By jftaylor21 in forum Qt Programming
    Replies: 2
    Last Post: 1st November 2009, 18:53

Tags for this Thread

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.