Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Move my video rendering label

    General and Desktop
    2
    4
    105
    Loading More Posts
    • 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.
    • vicky.vigia
      vicky.vigia last edited by

      Hi Team,

      I am trying this code and modified it a bit to create my own QLabel class, so I can support mouse move. The code is:

      void videoLbl::mouseMoveEvent(QMouseEvent *ev)
      {
          this->move(ev->x(), ev->y());
      }
      

      But, as soon as I move the video, it flickers and snaps back to the original position, like it repaints and get back to the original rendering position! Now, I am not sure, how to update the newly moved frame(s) to get rendered at the new position.

      Furthermore, if I try to move the same using this code, by hardcoding the position values, it never works, or gets repainted to the original position:

      void videoLbl::updatePlayerUI(QImage img)
      {
          //this->setAlignment(Qt::AlignCenter);
          this->setGeometry(10, 10, 40, 40);
          this->move(10, 10);
          this->setPixmap(QPixmap::fromImage(img).scaled(this->size(), Qt::KeepAspectRatio, Qt::FastTransformation));
      }
      
      

      I am using the following way in my main window class to render my custom Label class:

          m_videoLblDrag = new videoLbl(); // custom QLabel class instance
          m_videoLblDrag->m_vidplayer->loadVideo(fullpath);
          m_videoLblDrag->m_vidplayer->Play();
          ui->videoBox1->layout()->addWidget(m_videoLblDrag);
      

      Please, can you guide me, please?

      • Vicky
      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        Hi
        Did you try to pause the video, then move widget and resume video ?

        1 Reply Last reply Reply Quote 3
        • vicky.vigia
          vicky.vigia last edited by

          Hello,

          Many thanks for your reply. Yes, after I pause/stop the video, it works as expected! Now what?

          Best Regards!

          1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion last edited by

            Hi
            it means you should temporary pause it
            while user moves the Label to avoid the flashing.

            I assume " mouse move." means that user can select the label and move it around on screen.

            Also to make that look good, you should keep the offset into the WIdget where you "grab it"
            like they do there
            https://stackoverflow.com/questions/11172420/moving-object-with-mouse

            1 Reply Last reply Reply Quote 2
            • First post
              Last post