Thanks for the reply..
Could you please show a simple code example..?
I'm still in the middle of learning the timer and process event because I never use it before..
Thanks for the reply..
Could you please show a simple code example..?
I'm still in the middle of learning the timer and process event because I never use it before..
You have never called a method on a C++ object?
Syntax for a pointer is: objectVariable->methodName(argumentlist);
E.g.
or in one lineQt Code:
app->processEvents();To copy to clipboard, switch view to plain text mode
Qt Code:
To copy to clipboard, switch view to plain text mode
Cheers,
_
micmec (12th November 2013)
Sorry, but that's not what I meant. I mean some example of using it. Here is my code.
Qt Code:
ui(new Ui::Monitor) { ui->setupUi(this); this->count=0; for(int i=0;i<100;i++){ this->ui->lcdNumber->display(count); for(int j=0;j<5000000;j++){ } this->count++; app->processEvents(); } }To copy to clipboard, switch view to plain text mode
The truth is I have to make a monitoring program with Qt. My code just displays 99, not 0 to 99. Or is there another way to do monitoring with Qt?
Sorry if I'm too much asking...![]()
What You are monitoring ? Using infinite loop probably is a bad design.
Perhaps as a result of the optimization for loop is not executed because it is empty and You don't see changes of lcdNumber.
PS
I think I know where the problem is. Show us a main() function. I suspect that You are trying to play with GUI in constructor of main widget before start QApplication.
micmec (12th November 2013)
This is my main function
Qt Code:
#include "monitor.h" #include <QApplication> int main(int argc, char *argv[]) { Monitor w; w.show(); return a.exec(); }To copy to clipboard, switch view to plain text mode
Sorry if it's kind of embarassing because I'm still new to this. The programming languages that I have learned are just C and Java, but I'm still just a student so I just know the basics.![]()
If your compiler is gcc and optimization is O2 (default for qmake generated Makefiles), your empty loop is removed for sure. I don't know about other compilers.
If you really want to see the cool effect of changing a number on lcd widget (which is apparently your only goal here), connect a timer with a non-zero timeout to a slot, in which you increment a variable by 1 and display it.
micmec (12th November 2013)
Bookmarks