View Full Version : Marching Ant effect at the border of QRect

15th April 2011, 07:24
I just want to know
How can we give the Marching Ant effect to the Border of the QRect.
Can Anybody help me.?

15th April 2011, 08:26
Maybe set dash pattern (http://doc.trolltech.com/latest/qpen.html#setDashPattern) for QPen to [ ant_length, ant_space ] and use QTimer to animate dash offset (http://doc.trolltech.com/latest/qpen.html#setDashOffset) ?

15th April 2011, 18:24
me too thinking the same but,
if you have some hint then kindly share it with me.
so that I got some idea.
how to put the first step,
it will be definitely lead to some solution.

17th April 2011, 10:32
if you have some hint then kindly share it with me.
I already did. Keep the pen (with prepared dash pattern) as a member of some QObject-based class that will start the timer (maybe subclass of QGraphicsScene), and on each tick update the dash offset property of the pen. Next, assign this pen to your rect item and call rect->update(). If you move with the dash offset from 0 to ant_length + ant_space (and again from 0) it will look like the moving border, which is what you want to achieve, if I understood correctly.
I won't give any code, until I see some of yours ;)

18th April 2011, 06:28
Thanks man,
It works and I got what I want.
Thanks a lot man,

You helped me a lot yaar,
Thanks again,

In future also help if I post some problem,