In my filter call I know have the following:
state=new double(0); // initialize the member variable
cout << *state << endl; // prints 0
updateProgressBar * me=new updateProgressBar(state, this); // this holds the timer and the events with a pointer to the state
ds->Filter(min, max,s, state); // pass the same pointer to state to check on the progress
state=new double(0); // initialize the member variable
cout << *state << endl; // prints 0
updateProgressBar * me=new updateProgressBar(state, this); // this holds the timer and the events with a pointer to the state
ds->Filter(min, max,s, state); // pass the same pointer to state to check on the progress
To copy to clipboard, switch view to plain text mode
the updateProgressBar code:
updateProgressBar
::updateProgressBar(double* state,
QObject *parent
) : status
(state
), pa
(parent
),
QObject(parent
) // initialize {
startTimer(20); // update every 20 miliseconds
}
// this will be called when the timer times out
{
std::cout << "Timer ID:" << event->timerId() << std::endl;
if (*status==100) { // finished?
killTimer(event->timerId());
}
std::cout << "sending " << *status << std::endl; // !!!
}
updateProgressBar::updateProgressBar(double* state, QObject *parent)
: status(state), pa(parent), QObject(parent) // initialize
{
startTimer(20); // update every 20 miliseconds
}
// this will be called when the timer times out
void updateProgressBar::timerEvent(QTimerEvent *event)
{
std::cout << "Timer ID:" << event->timerId() << std::endl;
if (*status==100) { // finished?
killTimer(event->timerId());
}
std::cout << "sending " << *status << std::endl; // !!!
const QEvent::Type MyEvent = (QEvent::Type)1234;
QEvent * message=new QEvent(MyEvent);
QCoreApplication::sendEvent(pa, message);
}
To copy to clipboard, switch view to plain text mode
And i receive the event in my parent frame:
void intensityframe2
::customEvent(QEvent * events
) { cout << "received an event" << endl;
int value=(*state); //cast to int
m_ui->progressBar->setValue(value); //display on the screen
}
void intensityframe2::customEvent(QEvent * events) {
cout << "received an event" << endl;
int value=(*state); //cast to int
m_ui->progressBar->setValue(value); //display on the screen
}
To copy to clipboard, switch view to plain text mode
This code works, but i've got one pointer problem.
After even one timer loop, i display the value of the pointer (see !!!) and then i send an event to the parent window so he knows he has to check on the value of the state/progress and display it. But even when no assignments have been made to value of the pointer is set to a strange value: like for example: 2.1305e-313
The value of that double is allocated on the heap, so i dont immediately see a reason why the value of that pointer isnt just 0 and not 2.1305e-313 or so...
ps: even when i place the timer in my mainwindow and delete the updateProgressBar class, the value gets changed :/
Bookmarks