Welcome! Log In Create A New Profile

Advanced

Assignment 2 - Question 1

Posted by brettc 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar Assignment 2 - Question 1
June 17, 2010 10:10AM
thread should run for a fixed time from when it was started unless it was explicitly stopped by the user.

How long did you all run the thread and how did you check? Just have a counter to count the number of fluctuations? Or is there a way to time a thread running time?
avatar Re: Assignment 2 - Question 1
June 17, 2010 12:21PM
You could either use a counter or store the starting time and compare the current time to the starting time. Just remember to make your data reads and writes atomic in re-entrant functions
avatar Re: Assignment 2 - Question 1
June 17, 2010 12:45PM
I forgot about the QTimer class. If you need a specific time period to lapse, you can use the QTimer:: slingshot static function.
Re: Assignment 2 - Question 1
June 17, 2010 03:44PM
I just let it run to generate 200 numbers each time start is pressed. If the user presses stop and then start then the counter is reset to 200.
Re: Assignment 2 - Question 1
July 01, 2010 09:37AM
hallo guys

having trouble with compiler, maybe you can help?

in my file "stockMarcketWatch.h" I have the following code:

Language: C++ (QT)
#include <QTimer>     class StockMarketWatch : public QTimer { Q_OBJECT public slots: void updateStockPrice(); };


but this gives me a linker error.
to get by this I can remove the Q_OBJECT macro, then it compiles,
but will my slot still work?
avatar Re: Assignment 2 - Question 1
July 01, 2010 10:44AM
Your slot won't work without the Q_OBJECT macro.

If you say you're getting a linker error[1] then I'm assuming the error itself has something to do with QMetaObject. I would hazzard that the auto-generated file moc_StockMarketWatch.cpp is not being included in your compile/link. If you're using Dev-C++, try regenerating your project file (ie using qmake).

I'm lazy, I use VS2008 and I've got the Qt add-in. Every time I make a change that would involve MOC, the plugin automatically does necessary changes to the project settings for me. Other IDEs don't always do this and you have to regenerate the project file manually.



[1] In future, if you get an error message from the compiler or the linker, please include the error message with your post. It often helps diagnose the problem.
Sorry, only registered users may post in this forum.

Click here to login