Thanks Sir,

Originally Posted by
wysota
Yes you can, qApp is a global pointer to the application instance.
I have tried this i mean with qapp->processEvents(); but it showed me error that qapp is not declared in this scope.

Originally Posted by
wysota
It won't work that way. processEvents() has to be called inside your do_something function inside the loop at each (well... not each as in every but as in sometimes) iteration.
There is no magic here. processEvents() performs a one time scan over pending events and processes them. You have to call it every time you want pending events to be processed.
Thanks now i came to know what actually happens when this function gets called. It checks for any pending event during the execution in do_something(); so that if user clicks any button or does something it will also be executed as:-
Void Square::do_something()
{
for(i=o;i<100000000;i++) {
qapp->processEvents();
...
....}
}
Void Square::do_something()
{
for(i=o;i<100000000;i++) {
qapp->processEvents();
...
....}
}
To copy to clipboard, switch view to plain text mode
But sir how can i use qapp created in main.cpp in the outer .cpp class? Those are separate files. I have only included its header in sample.cpp where all slots are implemented. qapp is not even detected in Sample.cpp, giving same error. Or do i have to include any file in Square.cpp?
////main.cpp////
#include <QApplication>
#include <QtGui>
#include "sample.h"
int main(int argc, char *argv[])
{
sample *dialog = new sample;
dialog->show();
qapp->connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
return app.exec();
}
////main.cpp////
#include <QApplication>
#include <QtGui>
#include "sample.h"
int main(int argc, char *argv[])
{
QApplication *qapp(argc, argv);
sample *dialog = new sample;
dialog->show();
qapp->connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Thanks again & sorry for disturbing you so much.
Bookmarks