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. How to display an image in QVideoWidget?
Forum Updated to NodeBB v4.3 + New Features

How to display an image in QVideoWidget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.9k 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.
  • sonichyS Offline
    sonichyS Offline
    sonichy
    wrote on last edited by sonichy
    #1

    I want to add a LOGO image display in QVideoWidget when start-up or stop:
    alt text

    And display cover image of audio file :

    QImage imageCover = player->metaData(QMediaMetaData::ThumbnailImage).value<QImage>();
    

    alt text

    video = new QVideoWidget;
    connect(player,SIGNAL(stateChanged(QMediaPlayer::State)),SLOT(stateChange(QMediaPlayer::State)));
    void MainWindow::stateChange(QMediaPlayer::State state)
    {
        qDebug() << state;
        if(state == QMediaPlayer::StoppedState){
            video->update();
        }
    }
    

    Start useful, stop useless:

    video->setStyleSheet("background-color:blue;");
    

    Useless:

    video->setStyleSheet("background-image:url(:/icon.png);");
    

    Useless:

    QPalette pal = video->palette();
    pal.setBrush(QPalette::Window, QBrush(QPixmap(":/icon.png")));
    video->setAutoFillBackground(true);
    video->setPalette(pal);

    https://github.com/sonichy

    J.HilkJ 1 Reply Last reply
    0
    • sonichyS sonichy

      I want to add a LOGO image display in QVideoWidget when start-up or stop:
      alt text

      And display cover image of audio file :

      QImage imageCover = player->metaData(QMediaMetaData::ThumbnailImage).value<QImage>();
      

      alt text

      video = new QVideoWidget;
      connect(player,SIGNAL(stateChanged(QMediaPlayer::State)),SLOT(stateChange(QMediaPlayer::State)));
      void MainWindow::stateChange(QMediaPlayer::State state)
      {
          qDebug() << state;
          if(state == QMediaPlayer::StoppedState){
              video->update();
          }
      }
      

      Start useful, stop useless:

      video->setStyleSheet("background-color:blue;");
      

      Useless:

      video->setStyleSheet("background-image:url(:/icon.png);");
      

      Useless:

      QPalette pal = video->palette();
      pal.setBrush(QPalette::Window, QBrush(QPixmap(":/icon.png")));
      video->setAutoFillBackground(true);
      video->setPalette(pal);
      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @sonichy hi,
      sadly I'm not well versed with QVideoWidget. But I can tell you what I would attempt to do.

      Derive QVideoWidget into your own custom class.
      Give it a member that can Display an image. e.g QLabel
      hook into the resizeEvent and use it to move the Label to the correct spot.
      add an image setter and make a logic to hide/show the Label when a video is played or not.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      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