Sunday, June 14, 2009

Street children still in great demand in political processions

While flipping through the pages of today's issue of The Daily Star, although I felt no concern for the original news item, the little boy in front of the procession in the above picture caught my eyes.

It's commonplace in Bangladesh to hire unemployed people to participate in political procession so that politicians can show off their fake strength to the commoners. But can't the children be spared? We all know that these street children do this only for money, say 100 Tk. at best. Can't the politicians think a bit different from as they do now and extend their hands to ameliorate the frustrating condition of the street / slum children?

Sunday, May 3, 2009

Qt : set background image of a custom widget

When I first needed to get a background image for my custom widget in Qt 4.5, 2 solutions came to my mind. Here I have described how I failed with those seemingly working solutions with no satisfactory explanation, let alone a compelling one, and the working solutions suggested by the people at QtCentre forum.

(1)Using QPalette

Solution that does not work:

In the constructor of my custom widget -

QPalette palette;
palette.setBrush(QPalette::Window, QBrush(QPixmap(":/images/bg.png")));

As I said before, QPalette with brush derived from the background image did not work.

Solution that works:

Override QWidget's paintEvent(QPaintEvent* pe) method -

QPainter* pPainter = new QPainter(this);
pPainter->drawPixmap(rect(), QPixmap(":/images/bg.png"));
delete pPainter;

(2) Using StyleSheet

Solution that does not work:

It's intuitive that setting stylesheet property background-image should be sufficient to get a background image for your custom widget (that inherits QWidget class).

setStyleSheet("background-image: url(:/images/bg.png)");

Solution that works:

- Set style sheet with the above statement in the constructor.
- Override QWidget's paintEvent(QPaintEvent* pe) method -

QStyleOption styleOption;
QPainter painter(this);
style()->drawPrimitive(QStyle::PE_Widget, &styleOption, &painter, this);

If interested, you may go through the relevant thread.

Sunday, April 26, 2009

A few C++ Quirks

It's very usual in Java to initialize something which is constant throughout the class as static const within the class definition in the following way:

private static final String MAX_THREADS = 5;

After coding in Java for BlackBerry development for a few months, when I started working with C++ Qt framework, I did it in the same manner:

static const QString TITLE_TEXT = "Title Text";

I got the error - only static const integral data members can be initialized within a class. Google led me to the following solution:

1) declare in header file - static const QString TITLE_TEXT;
2) initialize in cpp file - const QString ClassName::TITLE_TEXT = "Title Text";

In the second step, I tried prepending static but got error - 'static ' storage-class specifier illegal on members.

In Java, the mechanism of indirection for constructors is as simple as calling this() with necessary arguments. We often do this to keep the initialization code in only one place. In C++, when tried, I got the error - term does not evaluate to a function taking 3 arguments. When I replaced this with a custom function initialize() where all the initialization code were put together, it worked fine.

Working with multiple languages sometimes does give trouble :-(

Thursday, April 9, 2009

BlackBerry Development : error - Cannot run program "javac"

I had been away from BlackBerry development for about a month. In the mean time, I bought a new PC. Having installed BlackBerry JDE, I wrote a simple program. Then tried to build it. But as you know, error happens :(

I/O Error: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified

And then I recalled that jdk bin directory had not been added to the Path environment variable. I added C:\Program Files\Java\jdk1.6.0_02\bin , then built the project. The same error shows up again. Then I closed and reopened the workspace, built it. No luck. Then closed JDE, restarted JDE, opened the workspace, built the project and only then everything was fine!

Silly matters sometimes do cause trouble!

Monday, April 6, 2009

M. A. Latif is a member of the parliament

I've just gone through the story of parliament member M. A. Latif's obnoxious behavior in today's issue of Prothom Alo. (I could not provide the link of Prothom Alo's version since it seemed to me that their link does not work later.)

What Mr M. A. Latif can do to remind the people of his constituency, if not the whole nation, of his vibrant presence outside the parliament as a parliament member :

1. Include a chapter on his 'glorious' life so far in the textbooks for all classes. The students will read the same chapter in every class they pass. This chapter on M. A. Latif's life story and his contribution to the nation, in a broader sense to the world and humanity, will surely be a favourite one since the students will have to memorize a chapter less in every class if he can memorize the answers to questions of this chapter.

2. In front of his house, he may establish his statue and people passing by this statue must salute / offer 'salam' to it. People not performing this holy duty should undergo punitive measures like outright slap on the spot, saluting 10 times etc. To enforce this, some extra law-enforcers will be required and this will solve the unemployment problem for some people. Just imagine that in this time of recession and hardship, Mr M. A. Latif is offering job opportunities to some people and thus helping the humanity to survive!

3. I can't understand why Mr M. A. Latif condescends to talk himself to the people when he gets angry/misbehaves. He can appoint one of his party men for staging a outragious show of crude and rude behavior. Then the wicked newspapers will not able to say that Mr M. A. Latif misbehaved with A, B, C etc. because he didn't do it!

(Don't feel writing about this inferior instance of human being anymore... ... ... apology)

Thursday, March 12, 2009

How to Import kxml jar File to Your Project

This is my first technical write-up. I never felt like writing this sort of thing before. I've been working on BlackBerry application development for the last couple of months and faced a number of problems some of whose solutions were not easy to find out and required more effort and time than anticipated. So I thought that it would be a good idea to write down the solutions to problems that I faced.

Of late I had difficult time in XML parsing with BlackBerry API. The API worked fine for version >=4.3, even for version 4.2.1, but frustratingly failed for version which I tested with 8300-Vodafone simulator. I searched frantically for a solution to this exasperating problem but in vain. So I had to look for an alternative.

Here came the great kXML parser. I downloaded the jar file.

Importing a jar file to my project in JDE at first seemed an easy task. A little bit search led to my project's Properties -> Build and then Add to imported jar files. But this procedure failed miserably and showed -

Searching installed codfiles for alias 'kxml2-2.3.0'
Searching uninstalled codfiles for alias 'kxml2-2.3.0'
Module 'kxml2-2.3.0' not found.Error starting kXmlParserTest: Module 'kxml2-2.3.0' not found.

Here, kXmlParserTest is my workspace name.

Googling led me to the following workaround:

1. Create a different project, say kXmlProject.

2. Add the kXML jar file to kXmlProject through Add File to Project.

3. Go to kXmlProject's Properties -> Application and select Library in Project type option.

4. Now build the project

But the project build failed and showed : Error!: Missing stack map at label: 79
Error while building project

Again I resorted to googling and someone at one of BlackBerry developer forums wrote that this problem occurs due to incompatible binary structure of jar file and suggested a solution - preverify the kXML jar file. But how?

1. Go to your JDE installation folder, for Windows XP it is usually C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\bin

2. Copy the kXML jar file to bin folder.

3. Notice the preverify.exe file. This is the tool we'll use.

4. Now open your command prompt and change your current directory to your JDE installation directory.

5. execute the following command:

preverify -classpath "C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\lib\net_rim_api.jar" "your_kXML_jar_filename"

6. Notice that in C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\bin directory, another folder named output has been created. Preverified jar file resides here. Copy the preverified jar file with the same name that the non-preverified jar file has.

7. Now replace the non-preverified jar file with the verified one. Remove the former from your kXmlProject and add the latter.

Then the project build was successful and this project was going to be used as a library for my other project, say kXmlParserTestProject.

I tried to build kXmlParserTestProject but project build failed. Then was the time for fixing project dependencies.

- Go to kXmlParserTestProjec's Project Dependencies and check kXmlProject.

Then everything worked fine. Don't stop reading here. Go on...

The day after I fixed this issue of jar file import spending a lot of time and effort, my colleague Bikas who was working with me in the same project, informed me that two cod files were created for two different projects. But single cod file was convenient for installation. While I was googling for a workaround, Bikas, just out of sheer curiosity whether it worked or not, removed the kXmlProject library project, removed project dependencies and added the preverified jar file as a normal java file to the project. This simply worked fine X-(

Useful links:

How To - Compile a jar file into a BlackBerry Library

Friday, February 13, 2009

Textbook crisis

AL-led grand alliance has assumed power at the outset of this year and soon has been faced with a veritable challenge which has been plaguing Bangladesh for the last several years - textbook crisis.

I wonder how publishers and their accomplices - some venal officials of concerned authorities can perpetrate such a heinous act like keeping our secondary school students, the future of our country, as hostage for satiating their greed for filthy lucre!

It seems to me that measures taken to get rid of the crisis on the part of government are lackadaisical. If the government would have given this issue its due attention from the onset, the situation could not deteriorate to such a grave extent. Failure to face the crisis successfully may start to undermine the trust of people in current government's ability to run the country properly.

The perception that education minister Nurul Islam Nahid is a man of integrity engenders expectation among us that he will leave no stone unturned to resolve this issue once and for all.

[ later published as a letter in The Daily Star on February 16, 2009 ]

Wednesday, January 28, 2009

Advices never going to be heeded

While I was on my way to office today, I noticed a banner in front of press club. On the banner a man named Mohammad Abdul Ali sought notice of incumbents and said, "I want to share my well-thought-out ways to lessen the severity of traffic jam of Dhaka city by 60%. I also want to share my thoughts as to how Bangladesh can make advancement in agricultural sector." His name and mobile number were written at the bottom.

Eccentricity is not always insanity. But in our country we tend to deem these two words synonymous. There are still some people who profoundly think for the betterment of the country disregarding whom to take their thoughts to be considered and if accepted, implemented. We even do not have such kind of opportunity that facilitates people's participation in terms of thoughts or plans regarding affairs of greater national interest.

An idea can change your life. In a similar vein, an idea can also change the fate of a nation! The sooner our leaders realize this fact, the better our chance to stand as a developed nation.

Kutumbari - nice but deterred by exorbitant price!

Yesterday Erfan, one of my colleagues shared with me a link to a page of Prothom Alo where a cosy restaurant named Kutumbari situated in front of Lalmatia Women's College was introduced and its Bar-B-Q item was highlighted. With a little googling, Erfan discovered that this restaurant had their own website! Since the college is at stone's throw from our office, he was curious to know the location. I had an opportunity to go there with some of other colleagues before. We together with Bikas, another of my colleagures decided to give that restaurant and its Bar-B-Q item a try.

We went there at about 5:30 pm. The ambience was obviously pleasant. But the sight of couples sitting unabashedly too close served an irritating distraction ;) I figured out that this place must be a hotspot for the couples. The women's college is at stone's throw. Romeos loiter around. He and she get together and pass pleasant time here. Another amusing sight was that a long coconut tree pierced the construction of the restaurant. The developers did not cut it and I thought it was a wise decision in a sense that it provided the customers with an amusing sight.

Then came the question of food. We ordered beef Bar-B-Q, naan and soft drinks. What vexed me most was exorbitant price compared to the quality of food. The naan that cost 25 taka was at best 15 taka in any ordinary restaurant. Nonetheless, it was providing an ambience that is absent in ordinary restaurants and that desired ambience came with a price indirectly. Justified.

The food was of mediocre quality, nothing sort of exceptionally pleasant gustatory experience. We hurried and finished soon and left the place with an ambivalence as to whether this place was worth visiting again.

Monday, January 26, 2009

DU Teachers' Negligence to Their Students

I have just gone through today's editorial of The Daily Star entitled "Greeting Spree in DU", much to my chagrin.

DU teachers have a glorious legacy of guiding the nation in time of crisis. But it is sheer outrageous and disconcerting that a good number of teachers of DU indulge in negligence of their duties being oblivious to their foremost duty. When I was a student of DU, in time of unscheduled closure due to political clashes, I used to wonder why our beloved and respected teachers could not condescend to take necessary steps to break the stalemate so that their students could suffer a little less session jam! Nevertheless, when a political figure like Tarique Zia was imprisoned on charge of corruption, they did not hesitate to make a statement demanding his unconditional release.

Respected DU teachers should keep in mind that it is their acts and devotion to their students, not their academic position or political affiliation, that matters most to the students as well as the conscious people of the country.

[ A slightly moderated version of this post was later published as a letter in The Daily Star on February 01, 2009 ]