[Qt-interest] repaint()

phil prentice philp.cheer at talktalk.net
Tue Sep 21 14:38:30 CEST 2010


Hi everyone

  I would be grateful for a little help using paintEvent().  I have an 
application that has a "Continuous Button". I have implemented the slot using 
the following basic code.
void VIwindow::continuousSlot()         // SLOT
{
  static bool running = false;
  if(m_continuousButton->text() == "Stop")
  {
    running = false;
    return;
  }
  else
  {
    running = true;
    m_continuousButton->setText("Stop");
    repaint();  // Force a direct update.   Works!!!
    for(;;)
    {
       // Update some widgets with data ready to be redrawn
      repaint();  // The widgets are not being drawn????
      // Check for stop being pressed.
      QCoreApplication::processEvents();
       if(!running)
         break;
    }
    m_continuousButton->setText("Continuous");
  }
}

The mechanism works very well except the repaint in the for loop does not do 
anything.  I know this is probably a very basic question, but why??

Thankyou for your help

Phil



More information about the Qt-interest-old mailing list