Hey guys,
I have a dialog widget setup to be a custom splash screen.
I am overriding paintEvent to draw some boxes on the widget.
I have a QTimer setup to run a method every half second or so.
This method updates an array and does a repaint() wich calls
paintEvent. The code in paintEvent draws the boxes on the dialog
with different opacities based on values in the array.
My problem is that my QTimer is not triggering my method.
Here is my code:
CINWaitSplash
::CINWaitSplash(QWidget *parent, Qt
::WindowFlags f
){
// Main Event Timer
m_timerMain
= new QTimer(this);
connect(m_timerMain, SIGNAL(timeout()), this, SLOT(FillTable_SnakePattern()));
m_timerMain->setInterval(100); // Start our Timer 1000 = 1sec
m_timerMain->setSingleShot(false);
}
CINWaitSplash::CINWaitSplash(QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f)
{
// Main Event Timer
m_timerMain = new QTimer(this);
connect(m_timerMain, SIGNAL(timeout()), this, SLOT(FillTable_SnakePattern()));
m_timerMain->setInterval(100); // Start our Timer 1000 = 1sec
m_timerMain->setSingleShot(false);
}
To copy to clipboard, switch view to plain text mode
My MainWindow has a routine that calls these to start and stop the timer:
void CINWaitSplash::Start()
{
InitTable(); // Start A Blank Table
this->show(); // Show Dialog
m_timerMain->start();
}
void CINWaitSplash::Stop()
{
m_timerMain->stop();
this->hide(); // Hide Dialog
}
void CINWaitSplash::Start()
{
InitTable(); // Start A Blank Table
this->show(); // Show Dialog
m_timerMain->start();
}
void CINWaitSplash::Stop()
{
m_timerMain->stop();
this->hide(); // Hide Dialog
}
To copy to clipboard, switch view to plain text mode
So when I call Start() it displays my Dialog Widget and "starts" the timer. My MainWindow sleeps for like 10 seconds then calls Stop(). It is doing that just for testing. Anyways... my FillTable_SnakePattern() method never gets triggered by the timer. At the end of the method I am doing a repaint() like I said earlier. I am going to use this to pop up a slash screen when you do a search in my program. When the search is done, it will call Stop() and hide the splash screen.
Am I doing something wrong here? I am assuming the timer runs on another thread... right?
So if I accessed my splashscreen class like this from my mainwindow:
CINWaitSplash* CINMainWindow::INWaitSplash() { return m_qtINWaitSplash; }
I would be able to start and stop it like so:
INMainWindow()->INWaitSplash()->Start();
// sleep 10 seconds
INMainWindow()->INWaitSplash()->Stop();
Bookmarks