<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to setPos in QMovie?]]></title><description><![CDATA[<p dir="auto">How to move QMovie- gif file from bottom left to bottom right?<br />
Below is my code<br />
@<br />
#include "mainwindow.h"<br />
#include "ui_mainwindow.h"<br />
#include &lt;QPushButton&gt;<br />
#include &lt;QGridLayout&gt;<br />
#include &lt;QLabel&gt;<br />
#include "ticker.h"<br />
#include &lt;QMainWindow&gt;<br />
#include &lt;QGraphicsScene&gt;<br />
#include &lt;QGraphicsRectItem&gt;<br />
#include &lt;QGraphicsView&gt;<br />
#include &lt;QMovie&gt;<br />
#include &lt;QTimer&gt;</p>
<p dir="auto">MainWindow::MainWindow(QWidget *parent) :<br />
QMainWindow(parent),<br />
ui(new Ui::MainWindow)<br />
{<br />
ui-&gt;setupUi(this);<br />
QWidget *window= new QWidget;<br />
window-&gt;setWindowTitle("My App");</p>
<pre><code>ml = new WidgetMarqueeLabel(this);
ml-&gt;setTextFormat(Qt::RichText);
ml-&gt;setAlignment(Qt::AlignBottom);
ml-&gt;setText("this is a very long text, weather is very hot");
ml-&gt;setFont(QFont("Arial", 20,20));

QGridLayout *layout= new QGridLayout;
video();

QLabel* label= new QLabel;
QMovie* movie = new QMovie("/home/ubuntu/Desktop/graphic.gif");
label-&gt;setMovie(movie);
movie-&gt;start();

QTimer *timer = new QTimer();
connect(timer,SIGNAL(timeout()),movie,SLOT(move()));               //??How to move QMovie
timer-&gt;start(60);

layout-&gt;addWidget(videoWidget,0,0);
layout-&gt;addWidget(videoWidget1,0,1);
layout-&gt;addWidget(ml,1,0,1,2);
layout-&gt;addWidget(label,2,0,1,2);

window-&gt;setLayout(layout);
window-&gt;show();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void MainWindow::video()<br />
{<br />
playlist= new QMediaPlaylist();<br />
player= new QMediaPlayer;<br />
videoWidget = new QVideoWidget;<br />
playlist-&gt;addMedia(QUrl::fromLocalFile("/opt/VP.mp4"));<br />
player-&gt;setPlaylist(playlist);</p>
<pre><code>playlist1= new QMediaPlaylist();
player1= new QMediaPlayer;
videoWidget1 = new QVideoWidget;
playlist1-&gt;addMedia(QUrl::fromLocalFile("/opt/hotgirl.mp4"));
player1-&gt;setPlaylist(playlist1);

player-&gt;setVideoOutput(videoWidget);
player1-&gt;setVideoOutput(videoWidget1);
playlist-&gt;setCurrentIndex(1);
playlist1-&gt;setCurrentIndex(1);
player-&gt;play();
player1-&gt;play();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">MainWindow::~MainWindow()<br />
{<br />
delete ui;<br />
}</p>
<p dir="auto">void MainWindow::move()<br />
{<br />
setPos(x()-10,y());</p>
<p dir="auto">}<br />
@</p>
]]></description><link>https://forum.qt.io/topic/52015/how-to-setpos-in-qmovie</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Nov 2026 07:55:53 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/52015.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 09 Mar 2015 10:01:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to setPos in QMovie? on Tue, 10 Mar 2015 01:58:32 GMT]]></title><description><![CDATA[<p dir="auto">Thanks Chris. U are an angel.</p>
]]></description><link>https://forum.qt.io/post/264449</link><guid isPermaLink="true">https://forum.qt.io/post/264449</guid><dc:creator><![CDATA[houmingc]]></dc:creator><pubDate>Tue, 10 Mar 2015 01:58:32 GMT</pubDate></item><item><title><![CDATA[Reply to How to setPos in QMovie? on Mon, 09 Mar 2015 12:11:45 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome,<br />
There are a couple of problems with your code.</p>
<p dir="auto">First of all you're leaking memory like crazy. <em>window</em> does not have a parent and you never delete it, so it's a leak. The same goes for <em>movie</em>, <em>timer</em>,  <em>playlist1</em>, <em>player1</em> and <em>videoWidget1</em>.<br />
Then, you make a <em>ml</em> a child of <em>MainWindow</em> (by passing <em>this</em> in the constructor), but put it in a layout of <em>window</em>, which switches its parent to <em>window</em>. While not an error, it's just wasteful. Just don't give it a parent if it's going in a layout.</p>
<p dir="auto">Now to the moving problem. You didn't write what <em>setPos</em> is, but I assume your intention is to animate the position of label displaying the movie.<br />
In your code you placed the label inside a layout, so it's the layout that governs the size and position of the label. You can't override it.<br />
If you want to manually set the position of the label don't put it in a layout. Give it a parent (e.g. <em>window</em>) and then use setGeometry.</p>
<p dir="auto">Also, there's a cleaner way to achieve the same without a timer. Check the example of <a href="http://doc.qt.io/qt-5/qpropertyanimation.html#details" target="_blank" rel="noopener noreferrer nofollow ugc">QPropertyAnimation</a>.</p>
]]></description><link>https://forum.qt.io/post/264332</link><guid isPermaLink="true">https://forum.qt.io/post/264332</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Mon, 09 Mar 2015 12:11:45 GMT</pubDate></item></channel></rss>