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. resize the video according to my controls widget
Forum Updated to NodeBB v4.3 + New Features

resize the video according to my controls widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 404 Views 2 Watching
  • 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.
  • M Offline
    M Offline
    MAmr
    wrote on last edited by
    #1

    vd.png

    I want all the videos to display with the same size as my widget or my label, (both of them have the same size), and remove the black border.

    here is my code:

    void ViewMedia::playMedia()
    {
        if(!_listMedia.isEmpty())
        {
            Contexthelp contexthelp = _listMedia.first();
    
            QByteArray imageFormat = QImageReader::imageFormat(contexthelp.getMedia());
            if(!imageFormat.isEmpty()) // media is image
            {
                _label->setPixmap(contexthelp.getMedia());
                _label->setScaledContents(true);
                _layout->addWidget(_label);
                _widget->setLayout(_layout);
    
                QTimer::singleShot(1000, this, &ViewMedia::playNext);
            }
            else // media is video
            {
    
                _label->clear();
                _player->setVideoOutput(_videowidget);
                _player->setMedia(QUrl::fromLocalFile(contexthelp.getMedia())); // video path
                _layout->addWidget(_videowidget);
    
    //            _videowidget->setFixedHeight(_widget->height());  // I tried to fix the size of the video but it did not work
    //            _videowidget->setFixedWidth(_widget->width());
                _player->play();
    
                connect(_player, &QMediaPlayer::stateChanged, this, &ViewMedia::stateChanged); // Check video statement
    
                connect(_player, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error),[=] // QMediaplayer error occured
                        (QMediaPlayer::Error error){ qInfo()<< "error occured media player : " << error;
                });
            }
        }
        else
        {
            qDebug()<< "listMedia is empty";
            downloadContexthelp();
        }
    }
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      MAmr
      wrote on last edited by
      #2

      I'm working on Qt5

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        Are these lines you want to remove part of the original video ?
        Are you using layouts ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          Are these lines you want to remove part of the original video ?
          Are you using layouts ?

          M Offline
          M Offline
          MAmr
          wrote on last edited by
          #4

          @SGaist Hii,

          no they are not part of the video, it's just in relation to the resolution of the widget.
          Yes I used layout

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Then please show how you setup your GUI.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            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