Skip to main content

Posts

Showing posts from August, 2010

File-based Logging in Qt

[This entry is a refinement of an article I found here ] Testing applications for mobiles or embedded systems is very hard most of the time because I'm not always able to debug the application on the device. One solution was to write some debugging lines inside the program, and when the program passes each of these lines, the line will be written to a text file. Then I can simply open the text file and see how the application went or where it stopped. Here it how it goes: - Before the main(), I write: using namespace std; ofstream logfile; void SimpleLoggingHandler(QtMsgType type, const char *msg) { switch (type) { case QtDebugMsg: logfile << QTime::currentTime().toString().toAscii().data() << " Debug: " << msg << "\n"; break; case QtCriticalMsg: logfile << QTime::currentTime().toString().toAscii().data() << " Critical: " << msg << "\n...

Mobile Softkeys in Qt

[Nokia Qt SDK v1.0 - 23 June 2010 ] When programming for Symbian, it is essential to make use of the available buttons. Here is how to assign the left and right buttons. //Left Button QAction *okSoftKeyAction = new QAction(QString("Ok"), this); okSoftKeyAction->setSoftKeyRole(QAction::PositiveSoftKey); connect(okSoftKeyAction, SIGNAL(triggered()), this, SLOT(mySlot1())); addAction(okSoftKeyAction); //Right Button QAction *cancelSoftKeyAction = new QAction(QString("Cancel"), this); cancelSoftKeyAction->setSoftKeyRole(QAction::NegativeSoftKey); connect(cancelSoftKeyAction, SIGNAL(triggered()), this, SLOT(mySlot2())); addAction(cancelSoftKeyAction); where the left button is the PositiveSoftKey and the right button is the NegativeSoftKey. And mySlot1() and mySlot2() are any slots I make or use. Notes: When trying this on the emulator of Nokia Qt SDK v1.0, I still see the original 'Options' and 'Exit' buttons. They are fake. When I tried i...

Prayer Times Calculations: Pure C++ Code

[25-March-2017] Update: For brothers and sisters in Indonesia or any country below the equator, thanks to Reza's comment ,  the code now works correctly. [18-January-2012 Update: I refined the code to make it easier and more elegant to use] [06-July-2011 Update: I found this page http://praytimes.org/calculation#Implementation ] This idea came to me when a friend of mine was asking for an 'offline database' for prayer times. I searched for algorithms to make my own database and almost all search results lead to the same algorithm. And all codes are divided into two categories: a simple but approximate one, and a complicated but precise one. I tried with the complicated one to understand it but it needs more time because of its nested functions and -unfortunately- it is not a priority right now. So I went with the easy one as a start. One thing I noticed is that every person is trying to make the ultimate use of the framework he is working on (mostly dotNet). But co...