Note that there are some explanatory texts on larger screens.

plurals
  1. POQPropertyAnimation reject to begin immediately after start() call
    primarykey
    data
    text
    <p>See code below. I have a button that starts the animation. The problem is that i see the animation only after SECOND button press. But when animation starts, i notice that it actually have been going since FIRST button press, because it starts from a moment = <code>[the time between 1 and 2 button press]</code>.</p> <p>The code: (sorry for overkill boost::shared_ptr)</p> <p><strong>WinWin.h</strong>:</p> <pre><code>#define LOGCOUT(x) { std::cout &lt;&lt; __FILE__ &lt;&lt; ":" &lt;&lt; __LINE__ &lt;&lt; " " &lt;&lt; x &lt;&lt; "\n"; } class WinWin: public QWidget { Q_OBJECT public: Q_PROPERTY(unsigned animprop READ getAnimProp WRITE setAnimProp); WinWin(); unsigned getAnimProp(); void setAnimProp(unsigned); protected: virtual void paintEvent(QPaintEvent *); public slots: void slotButtonClicked(); private: unsigned m_anim_prop; QPropertyAnimation *m_animation; QPushButton *m_button; }; </code></pre> <p><strong>WinWin.cpp</strong>:</p> <pre><code>WinWin::WinWin() : m_anim_prop(0) { m_animation = new QPropertyAnimation(this, "animprop"); m_button = new QPushButton(this); m_button-&gt;setText( "Start" ); m_button-&gt;move ( 40, 40 ); m_button-&gt;resize( 100, 30 ); m_button-&gt;show(); resize( 640, 480 ); connect( m_button.get(), SIGNAL(clicked()), this, SLOT(slotButtonClicked()) ); } unsigned WinWin::getAnimProp() { } void WinWin::setAnimProp(unsigned _prop) { LOGCOUT("anim " &lt;&lt; _prop); m_anim_prop = _prop; update(); } void WinWin::paintEvent(QPaintEvent *) { QPainter painter( this ); painter.setPen( QColor(0x00, 0x00, 0x00, 0xff) ); painter.drawLine( 0, 0, width(), m_anim_prop ); } void WinWin::slotButtonClicked() { m_animation-&gt;setDuration( 1000 * 4 ); m_animation-&gt;setStartValue( 0 ); m_animation-&gt;setEndValue( height() ); m_animation-&gt;setLoopCount( -1 ); // infinite number of loops // Fire! m_animation-&gt;start(); LOGCOUT( m_animation-&gt;state() ); // says: 2 } </code></pre> <p><strong>main.cpp</strong>:</p> <pre><code>int main ( int argc, char **argv ) { QApplication app(argc, argv); WinWin winwin; winwin.show(); return app.exec(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload