Archive for the ‘Programming’ Category

Qt5: New signal and slot syntax

Thursday, May 17th, 2012

I thought, that I should write about this topic, because it’s time to start my self-education project again and see how I can take new features of Qt in use. I’m not sure how useful this blog post is because there already is a nice wiki page available about the same topic on qt-project.org. But for those, who haven’t read the wiki page, this might be a bit shock – Yes, in Qt5 there is a new syntax for connecting signals and slots!

Don’t worry, your old code (Qt 4.x) doesn’t break and Trolls will continue the support of the old, string-based connection. So what’s new in the new signal-slot syntax then? Basically you can connect signals and slots using the following style shown in by the example below. Note that you still have to have Q_OBJECT macro defined in a class, which introduces signals or slots.

connect(sender, &Sender::valueChanged, receiver, &Receiver::updateValue );

Instead of using SIGNAL() and SLOT() macros, you can now also use C++ function pointers to connect signals and slots. In Qt5, you can connect signals to any member function of a class  i.e. they don’t need to be slots. Note that in the end, Qt slots are only class’ member functions. The “slots” keyword is only an empty define and used only by MOC (Meta Object Compiler) when parsing headers.

(more…)

Porting QtQuick1.X extensions to Qt5

Wednesday, March 7th, 2012

A friend of mine (@jan_ekholm/twitter and chakie/@freenode) developed a cool C++ VideoWidget using Qt a some time ago. The idea of making this kind of own custom widget, was that Qt’s multimedia isn’t the best multimedia kit on earth. The problem is that it’s not really a cross platform because it depends on underlying platform multimedia kit. For example on linux it may depend on streamer or phonon backend, on Windows it depends on DirectShow and on Mac on QuickTime. This also means that something that works on one platform, may not work on another platform.

One weird thing about Qt’s multimedia is that QML bindings are provided only by Qt Mobility’s multimedia module. Then again Phonon isn’t very efficient and it doesn’t have QML bindings. If using VLC with Qt, it’s almost impossible to make overlays (text) visible on a video. So Chakie made a solution, which doesn’t depend any of these, is a cross platform (Windows, Mac, Linux) and works quite nicely.

I thought that it would be great to port that QWidget/C++ based solution to QML. Actually, it was quite straight forward to do that, thanks to Chakie’s original solution, it took only a few hours to get the first version to work. Of course, fine tuning takes time, but it didn’t really take more than two hours to make the QML extension to show a video.

(more…)

Simple Guide to Port Qt4 QML App to Qt5

Monday, December 19th, 2011

 

I thought, that it could be a good idea to write a short post how to port an existing Qt4 QML application to Qt5. At first, if you are not familiar how Qt will change for the next version, you should read this doc: The Road to Qt 5. The one of the biggest changes is happening under to hood of QML / QtDeclarative module.  As Lars Knoll, wrote in the document, there is a new scene graph, which will replace the old QGraphicsView/QPainter based implementation. So basically what this means is that the gap between QML and HW gets smaller. In other words, in Qt5 you will get a kick ass performance for your QML applications plus extra features like shaders. Yes, you can also use shaders in your QML code!

(more…)

HTML5 for Mobile App Development?

Sunday, December 18th, 2011

Looks like HTML5 is the next buzz technology that every software consultancy company is desperately trying add their competence list. For some reason, it’s something that is predicted and announced to be in the next generation mobile devices. For example Tizen is said to support HTML5 and Samsung Bada mobile OS’s SDK/IDE already provides project templates to create HTML5 mobile apps. In addition to all this, web is full of different frameworks, which provide ways to build HTML5 based applications. I think one of the biggest expectations is that HTML5 is the “real cross platform technology for mobile application development”. Unfortunaly, I disagree.

I’ve been playing with HTML5 for couple of weeks now and I thought that I should share my view of HTML5 based mobile application development. My background is on traditional software development, programming languages and toolkits such as C/C++, Qt, iOS/Objective C, Python and Java. There is also a good reason, why I have never been interested in web technologies and reason is I don’t like the way web sites are built. For example I think the mix of HTML, Javascript and PHP looks confusing and structuring the code is rarely looks nice.  Another a big obstacle for me is that, I don’t like Javascript. I think, it’s more like a “toy programming language” for kids when comparing it to C++, Objective C, Java and Python.

But as I said, I’m not a web developer. It might be that I just haven’t seen a well structured web site or my inner resistance is just too much to let me to learn these technologies well enough.

(more…)