diff options
Diffstat (limited to 'misc_functions.cpp')
| -rw-r--r-- | misc_functions.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/misc_functions.cpp b/misc_functions.cpp new file mode 100644 index 0000000..a2e19a0 --- /dev/null +++ b/misc_functions.cpp @@ -0,0 +1,30 @@ +#include "misc_functions.h" + +#include <QTime> +#include <QCoreApplication> + +void delay(int p_milliseconds) +{ + QTime dieTime = QTime::currentTime().addMSecs(p_milliseconds); + + while(QTime::currentTime() < dieTime) + QCoreApplication::processEvents(QEventLoop::AllEvents, 100); +} + +//alternates between true and false every time it is called. useful for certain optimization +bool cyclic_function() +{ + static bool cycle = true; + + if (cycle) + { + cycle = false; + return cycle; + } + + else + { + cycle = true; + return cycle; + } +} |
