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. [SOLVED] What is wrong with my code when I use QVideoWidget?
QtWS25 Last Chance

[SOLVED] What is wrong with my code when I use QVideoWidget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.6k 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.
  • L Offline
    L Offline
    linuxer
    wrote on last edited by linuxer
    #1

    I use QVideoWideget to show video,but it didn't show video.But at the same time I can hear the sound.
    #include "widget.h"
    #include <QPainter>
    Widget::Widget(QWidget *parent)
    : QWidget(parent)
    {
    setAttribute(Qt::WA_TranslucentBackground);
    myPlayer=new QMediaPlayer;
    videoWidget=new QVideoWidget;
    mainLayout=new QHBoxLayout(this);
    myPlayer->setVideoOutput(videoWidget);
    videoWidget->setFixedSize(400,400);
    myPlayer->setMedia(QUrl::fromLocalFile("D:/next.avi"));
    mainLayout->addWidget(videoWidget);
    myPlayer->play();
    }

    Widget::~Widget()
    {

    }

    This is my code.It doesn't work in my PC,but it can work in my friend‘s PC.
    My OS is Windows 10 X64.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on last edited by
      #2

      Check what QString errorString() returns, that you have proper codec installed.
      Can you watch this avi in other program on your PC?

      L 1 Reply Last reply
      0
      • M Offline
        M Offline
        mcosta
        wrote on last edited by
        #3

        HI and welcome to devnet,

        have you tried to connect a slot to the QMediaPlayer::error() signal?
        You could understand what was wrong (missing video codec??)

        Once your problem is solved don't forget to:

        • Mark the thread as SOLVED using the Topic Tool menu
        • Vote up the answer(s) that helped you to solve the issue

        You can embed images using (http://imgur.com/) or (http://postimage.org/)

        1 Reply Last reply
        0
        • A alex_malyu

          Check what QString errorString() returns, that you have proper codec installed.
          Can you watch this avi in other program on your PC?

          L Offline
          L Offline
          linuxer
          wrote on last edited by
          #4

          @alex_malyu Yes,I can play it by other player.Does it due to I have installed two video players?I was in a mess.Maybe something wrong with my computer environment.
          Still thanks!
          P.S. My English is OK?haha

          1 Reply Last reply
          0
          • L Offline
            L Offline
            linuxer
            wrote on last edited by
            #5

            Hi,All
            I have solved this problem.Someone told me to install a K-Lite ,I did,and it runs well.
            But in our country,China,we never use this soft.Do I hava to install this? I can not force others who use my soft to install it .

            1 Reply Last reply
            0
            • A Offline
              A Offline
              alex_malyu
              wrote on last edited by
              #6

              Uncompressed avi is portable, but huge.
              Compression is usually done by 3rd party codec.
              Some codecs are installed on the system by default.
              But you need codec to be available on the system if AVI used it.
              Some viewers sometimes integrate codecs.
              That why I assume your other program can play it.

              K-Lite contains mostly widely used codecs.
              If you do not use such codec when creating avi, you do not have to have it installed.

              Fact that after installation

              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