Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, February 2007
Flipping of image on QPushButton continuously


Message 1 in thread

Hi,

I need to change an image on PushButton and a TextLabel for 10times 
continuously.....

But the image is not changing  ..... chk the sample code ......

After the while loop is completed ... it is showing the final image to be 
shown .......

I couldnt understand why the image is not flipping.....

n = 10
while(n > 0)
    {
        pushButton16->setPixmap( QPixmap::fromMimeSource( 
"digital_offhook.xbm" ) );
        textLabel1->setText( "OFFHOOK" );
sleep(1);
        repaint();
 
    }
    else
    {
         pushButton16->setPixmap( QPixmap::fromMimeSource( 
"digital_onhook.xbm" ) );
         textLabel1->setText( "ONHOOK" );
        sleep(1); 
        repaint();
    }
  n-- ;


Am i missing something??????

Thanks & Regards,
Hemanth Kumar Nakkina
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you



Message 2 in thread

On 23.02.07 12:55:20, Hemanth N wrote:
> Hi,
> 
> I need to change an image on PushButton and a TextLabel for 10times 
> continuously.....
> 
> But the image is not changing  ..... chk the sample code ......
> 
> After the while loop is completed ... it is showing the final image to be 
> shown .......
> 
> I couldnt understand why the image is not flipping.....

Because you don't let the Qt event loop run, which does the paintin. Use
a QTimer and a slot to flip the image.

Andreas

-- 
 [ signature omitted ]