<?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[Cant Reset slider position]]></title><description><![CDATA[<p dir="auto">Hi there,<br />
Here is my issue: when I reset the position of my slider it acts like if it's been moved while I just press on it.<br />
Here is a part of my code:<br />
@<br />
WinA::WinA(FenPrincipale *FenPr, QWidget *parent) : QWidget(parent)<br />
{</p>
<p dir="auto">Couleur = new QLabel;<br />
Hierar = new HierarchItem (FenPr, this);</p>
<p dir="auto">boutonItem = new QSlider(Qt::Horizontal,this);<br />
boutonItem-&gt;setGeometry(146,121,20,4);<br />
boutonItem-&gt;setRange(0,100);<br />
boutonItem-&gt;setValue(40);</p>
<p dir="auto">labelH = new QLabel(Hierar);<br />
labelH-&gt;move(71,102);<br />
labelH-&gt;setStyleSheet("color: #C9C9C9;");<br />
labelH2 = new QLabel(Hierar);<br />
labelH2-&gt;move(200,102);<br />
labelH2-&gt;setStyleSheet("color: #C9C9C9;");</p>
<p dir="auto">QObject::connect(boutonItem, SIGNAL(sliderPressed()), this, SLOT(DisplayItem()));<br />
QObject::connect(boutonItem, SIGNAL(valueChanged(int)), this, SLOT(SelectItem(int)));</p>
<p dir="auto">}</p>
<p dir="auto">void WinA::SelectItem(int posbH)<br />
{<br />
if(posbH==40)<br />
{<br />
//QObject::disconnect(boutonItem, SIGNAL(sliderReleased()), this, SLOT(TraitementLabelH()));<br />
//QObject::disconnect(boutonItem, SIGNAL(sliderReleased()), this, SLOT(TraitementLabelH2()));<br />
labelH-&gt;setStyleSheet("color: #C9C9C9;");<br />
labelH2-&gt;setStyleSheet("color: #C9C9C9;");<br />
}</p>
<p dir="auto">if(posbH&gt;40)<br />
{<br />
labelH-&gt;setStyleSheet(""+Couleur-&gt;text()+"");<br />
labelH2-&gt;setStyleSheet("color: #C9C9C9;");<br />
}</p>
<p dir="auto">if(posbH&lt;40)<br />
{<br />
labelH-&gt;setStyleSheet("color: #C9C9C9;");<br />
labelH2-&gt;setStyleSheet(""+Couleur-&gt;text()+"");<br />
}</p>
<p dir="auto">if(posbH&gt;90)<br />
{<br />
QObject::connect(boutonItem, SIGNAL(sliderReleased()), this, SLOT(TraitementLabelH()));<br />
}</p>
<p dir="auto">if(posbH&lt;10)<br />
{<br />
QObject::connect(boutonItem, SIGNAL(sliderReleased()), this, SLOT(TraitementLabelH2()));<br />
}</p>
<p dir="auto">}</p>
<p dir="auto">void WinA::TraitementLabelH()<br />
{<br />
this-&gt;close;<br />
}</p>
<p dir="auto">void WinA::TraitementLabelH2()<br />
{<br />
this-&gt;close;<br />
}</p>
<p dir="auto">void WinA::DisplayItem()<br />
{<br />
labelH-&gt;setText(Hierar-&gt;getlabelHier());<br />
labelH2-&gt;setText(Hierar-&gt;getlabelHier2());</p>
<pre><code>//Seconde Animation
QPropertyAnimation *animation = new QPropertyAnimation(labelH, "geometry");
animation-&gt;setDuration(153);
animation-&gt;setStartValue(QRect(138, 102, 60, 14));
animation-&gt;setEndValue(QRect(200, 102, 60, 14));
animation-&gt;start(QAbstractAnimation::DeleteWhenStopped);

//Seconde Animation
QPropertyAnimation *animation2 = new QPropertyAnimation(labelH2, "geometry");
animation2-&gt;setDuration(153);
animation2-&gt;setStartValue(QRect(138, 102, 60, 14));
animation2-&gt;setEndValue(QRect(71, 102, 60, 14));
animation2-&gt;start(QAbstractAnimation::DeleteWhenStopped);

QObject::connect(boutonItem, SIGNAL(sliderReleased()), this, SLOT(HideItem()));
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void WinA::HideItem()<br />
{<br />
//Seconde Animation<br />
animation3 = new QPropertyAnimation(labelH, "geometry");<br />
animation3-&gt;setDuration(153);<br />
animation3-&gt;setStartValue(QRect(200, 102, 60, 14));<br />
animation3-&gt;setEndValue(QRect(138, 102, 60, 14));<br />
animation3-&gt;start(QAbstractAnimation::DeleteWhenStopped);</p>
<pre><code>QObject::connect(animation3, SIGNAL(finished()), labelH, SLOT(clear()));

//Seconde Animation
animation4 = new QPropertyAnimation(labelH2, "geometry");
animation4-&gt;setDuration(153);
animation4-&gt;setStartValue(QRect(71, 102, 60, 14));
animation4-&gt;setEndValue(QRect(138, 102, 60, 14));
animation4-&gt;start(QAbstractAnimation::DeleteWhenStopped);

QObject::connect(animation4, SIGNAL(finished()), labelH2, SLOT(clear()));

boutonItem-&gt;setValue(40);
</code></pre>
<p dir="auto">}<br />
@</p>
<p dir="auto">As you can notice the position of the slider is reset through HideItem().<br />
I forgot to mention that I use stackedwidgets in my app and this problem happens when I come back to the widget. First of all, is it the right methode to reset the position? If not, how can I reset my slider properly? Thanks.</p>
]]></description><link>https://forum.qt.io/topic/51790/cant-reset-slider-position</link><generator>RSS for Node</generator><lastBuildDate>Sun, 02 Aug 2026 10:10:15 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/51790.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 01 Mar 2015 00:11:12 GMT</pubDate><ttl>60</ttl></channel></rss>