Posts Tagged ‘d-pointer’

FoodGarden – My First iOS Application

Monday, July 11th, 2011

My last post about iOS application development was based on my experiments of developing FoodGarden – a shopping list and recipe application. I will release FoodGarden via d-pointer in Apple’s AppStore, hopefully quite soon. This blog post is a short introduction for the application. Let’s watch the video first.

I wanted to keep the video short and present the most of the functionality what you can do with the app. I left the boring section out i.e. adding bunch of recipes, items and sections, which you can use when creating shopping lists and recipes.

I’ve been using FoodGarden as my shopping list application lately and it seems to work pretty well. At least I haven’t found any critical bugs or annoying features.

(more…)

Qt-HowTo: Private Classes and D-Pointers

Tuesday, January 19th, 2010

If you have ever looked at the Qt source code, you have probably noticed that they use private classes and d-pointers. At first time when I saw this, I thought that what the heck is that thing and what are all these Q_D() and Q_Q() macros? I am probably not the only one that was bit confused about what they really do and what do you gain by using them. This is one reason why I decided to write a small article of using d-pointers. Most of the stuff in this article is based on KDE TechBase documentation.

Before continuing let’s take a look at how the code looks when using d-pointers inside methods.

...
void MyClass::setFoo( int i )
{
    Q_D(MyClass);
    d->m_foo = i;
}

int MyClass::foo() const
{
   Q_D(const MyClass);
   return d->m_foo;
}
...

In the example above, there are two methods. One for setting the value and another one for getting the value from the internal member of the class. Usually you would introduce an instance variable (int m_foo;) in a private section of the class MyClass and then you modify or return the value of it. In the example above, you set the integer ‘i’ to the  instance member m_foo of the private class. Next you might ask what do you gain of using this approach instead of using a “traditional way”, as it’s done in the most of the C++ code.

(more…)