Comments, Code and Qt. Some words about the wonderful world of software engineering

18Sep/115

Easy threading with QtConcurrent::run()

Posted by kypeli

The following scenario is probably familiar to you: you are doing some heavy computing or IO intensive things in your app, like accessing a database, the filesystem or reading data from the Internet, that blocks your UI thread which leads to that the UI freezes. If you are writing a Qt app then probably the first thing that comes to your mind is to subclass QThread and implement the run() method (although you should not do that). But before you do that, you should take a look at Qt Concurrent and what it can offer. There is a good chance that what you need is already provided by the Qt Concurrent framework.

How I added threads to my app in 20 minutes

In this post I want to show you how I added threaded database access to my small podcast application for MeeGo, Podcatcher for N9. The use case I had at hands was that I added automatic cleanup of podcast episodes to Podcatcher for N9, which required some heavy database and filesystem access. This is the (naive) code (in short) that I originally had when cleaning up podcast episodes: QList channels = m_channelsModel->channels(); foreach(PodcastChannel *channel, channels) { PodcastEpisodesModel *episodesModel = m_episodeModelFactory->episodesModel(channel->channelDbId()); episodesModel->cleanOldEpisodes(m_keepNumEpisodesSettings, m_autoDelUnplayedSettings); }

Technorati Tags: , , , ,

30Jul/1119

Why QNetworkAccessManager should not have the finished(QNetworkReply *) signal

Posted by kypeli

I was recently writing some network code in Qt using QNetworkAccessManager and again I did the mistake I've already done a few times. The reason for my mistake was that QNetworkAccessManager provides the finished(QNetworkReply *) signal. There are essentially two ways to request some data from the net using QNetworkAccessManager. In the first approach you have the QNetworkAccessManager as an instance variable in your class and you connect the finished(QNetworkReply *) signal from the instance variable to your slot. This is a tempting solution as it provides a quick and easy solution to fetch some data from the net.

Technorati Tags: , , ,

5Jul/115

Sneak peek: Integrate your application with the Nokia N9 events view.

Posted by kypeli

I am working on a Qt C++ library that will integrate your application with the Nokia N9 MeeGo Harmattan event feed page. You can add and update items with your icon, text or even a list of images that will be shown on the event feed page. I still want to add some features and polish the code before publishing it, but the library will be open source. So here's a video demonstrating what the library already can do. Stay tuned! Update: The library has been published. More information here.

Technorati Tags: , , , , ,

3Jul/1122

Deploying Qt and Qt Quick applications on Windows

Posted by kypeli

I recently had to deploy a Qt Quick application on a Windows machine that did not have Qt installed explicitly on it. I think this is a pretty common use case that can cause quite some headache. You basically have two options if you want to deploy (or install) your Qt or Qt Quick based application to Windows. Either you can use the Windows Installer service directly or use some free or commercial utility to create a MSI based installer application that will deploy your application on Windows. Alternatively or at least as a first step you can package your application into a ZIP, or some other, package together with the necessary libraries that the application depends on. This is what I did and what I am going to explain here. When the package is extracted on the target machine, your Qt or Qt Quick application can be run from that directory just by launching the .exe file. Pretty neat. Below I will explain some important points on how you want to create the package that you want to distribute your Qt application in. In my case I deployed a Qt Quick application that used Qt/3D and QtWebKit.

Technorati Tags: , , ,

26Jun/1114

What is the developer story for the Nokia N9?

Posted by kypeli

The MeeGo Harmattan powered Nokia N9 has now been out for a couple of days. Nokia's developer pages has a whole section dedicated to the Nokia N9 and we also have some great UX guidelines available. But as an app developer I am really just interested in writing my code and deploying it on to the device or the emulator. I already wrote earlier that the "official" developer story around Qt SDK 1.1.2 did not work for me and I am still wondering if this approach will work really well in Windows and OS X. I have also read the blog post from Nokia Developer's Kate Alhola on how to develop Qt Component apps for MeeGo Harmattan in Ubuntu without Scratchbox. This lead me to conclude that Nokia now has at least three ways how developer can develop apps for the Nokia N9 and all of them have some issues.  All of these approaches are also described on pages that are hosted and maintained by Nokia which adds to the confusion.

Technorati Tags: , , , , ,