Should I use Qt containers or the std ones?

If you come from plain vanilla C++, you only know the C++ Standard Library with its containers like std::vector. If you know how to use them, you can accomplish your tasks pretty fast. But if you’re coming from an other language, the naming might be a bit odd. The Qt containers offer both, C++ style and Java style naming of methods. So coming from an other language the Qt ones might be easier to use.
The Qt containers use the COW (Copy on Write) technique to be able to create cheap copies of them. This technique uses an internal container to store all the data. This container is accessed by a pointer. If you copy the instance of e.g. the QList you get a new QList instance with a pointer to the exact same internal container. You can use the new list exactly like the old one. The internal container stays shared while the list is not modified. But any operation that modifies one of the lists, e.g. adding or removing of elements, will result in a detach before the modifying operation is performed. Detach means here, that the whole internal container is copied. After the detach you have two completely independent lists with two independent internal containers.

So if you pass a QList to a function or method (by value), the act of copying will be very cheap. As long as you don’t modify the list inside the function or method, you have saved yourself some RAM.

The std containers doesn’t use this technique to be fast and to know exactly how long each operation will take. If you pass a std::vector to a function or method (by value) the whole vector will be copied.

But be careful, Qt containers can have some strange behavior if you use them with C++14. If you use the new for(Element e: list) syntax, on a QList (that has been copied) you cannot be sure if it copies the internal container, because using the new syntax could modify it.

Right now I didn’t answer the question, which containers are the best ones to use. And in fact there is no golden answer to this question; there maybe never will. So the answer I can give you to this question today, is the same you maybe heard many times before at other topics: It depends. Obviously it’s overkill to use the Qt framework just because of its containers.

Maybe it’s better to use std, in fact many of the Qt containers use the std containers under the hood. But if you interact with the Qt library you will see, that you will tend to use the Qt containers. Just because it’s easier to use them, as to convert back and forth. And yes I know, some people recommend to use std instead of Qt as much as possible. Personally I use both, Qt for convenience and std if speed is an issue. The one thing I’m pretty sure about, is that there is no ultimate answer to this question.

[EN] Why I love the Qt framework

Everyone that knows me, knows that I love the Qt framework. Before I started programming in C++, Java was my primary programming language. I love the generics (yes, some of you will hate me for that opinion right now) and reflection. During my Java-time I used them very often to increase reusability.
But while studying we had do learn C++ and I hated it in the beginning. It felt so old and so stiff compared to Java. But in one lecture we used Qt, and it was even more terrible – in the beginning. Signals, Slots, QWidgets, … it was to much. After working with it for some time it felt better. What I really liked about Qt from the beginning was the Qt Designer. For the first time I was able to have fancy ui’s in C++ and don’t have to bother with a C api. In Java I had a graphical editor for Swing. So creating ui’s was now as easy as in Java, maybe a bit easier. But the results with Qt are much better and fancier.
After some reading and experimentation I began to understand how Signals and Slots work. From now on I really liked Qt. It was awesome. It was so easy to accomplish tasks, and it still is. If you build an application with an ui and some heavy stuff to calculate, or simply said two threads to communicate, it is very easy with Qt. Just use Signals and Slots to communicate between the threads and the Qt framework will deal with all the synchronization stuff (If you use them properly). You can also use Signals and Slots to loosely couple objects. The sender-object that emitted the Signal, does not know where it is going and the receiver-object does not know where it came from. So you easily exchange components, just like with dependency injection.
If I write an application and use the C++ standard library and Qt, I can be sure that it will compile and run on all the mayor platforms. A few months ago I switched from Windows to Linux. The reason why I did that can be found here Warum ich zu Linux wechsle if you can read German. I was so excited when I opened the project file of my Qt project. I developed the whole project in Windows and with a click of the „Compile & Run“ button it was running under Linux.
But the portability is not the only advantage. You have a huge Library with many classes solving different problems. If you want to use for example Network, no problem, just use it. The same goes for JSON support, XML, SQL, Bluetooth, OpenGL and many more. It’s just so convenient, you don’t have to search for a library, try to compile it and link it to your project, Qt does all that for you. So you don’t have to reinvent the wheel every time.
At the beginning I mentioned reflection in Java. You can use reflection in Qt with the help of moc (Meta Object Compiler). So every class that inherits from QObject knows what class it is and other information at runtime.

The things I mentioned here are just a subset of what Qt is capable of. KDE is using Qt to build an entire desktop environment and other programs. And they are not the only ones using Qt, just have a look at the Wikipedia page of Qt and see companies like the European Space Agency, DreamWorks and Siemens.

[EN] How to work on your projects on multiple devices

At the beginning of my programming-life I’ve never thought of synchronization of my projects as an issue. Back at the time I only had a Computer standing in my room. Then I got a Laptop from the company I worked for back at the time. Still, synchronization was not an issue by now because I kept private and work separate. But the whole journey began when I started studying and I bought myself a Laptop. In the beginning I used an USB-drive to copy my workspace on, after I finished on one device, and copied it to the other machine then. It was simply ugly… After a few weeks I had hundreds of different versions, because I worked a bit on the Laptop, forgot to copy it to my Pc but wanted to save the possible progress I made.
The second step was a tool I knew from work: Mercurial, a version control system. Now I could just commit my changes and merge them. For syncing I used my own webserver, where I hosted a Mercurial server. No different versions of the same code, I thought was the result. But I was so wrong. In order to be in sync I needed to make an commit and push it to my server. There lies the problem. Sometimes I forgot to commit, sometimes I was just lazy and sometimes the code was not compilable, and I knew the „golden“ rule from work: „Commit only compilable code“. So there where still different versions of my code. The usage of an separate branch dedicated to my „in-development“ code didn’t fix the problem either. It fixed the problem with the rule but I still forgot to commit and push sometimes.
My current solution came with the „cloud era“. Since I’m concerned about privacy I don’t use the commercial clouds like Google Drive or Dropbox. First I hosted my own ownCloud (version 4 back then) server, after several issues with disappearing files I switched to Seafile. Seafile serves me as my cloud since then. I use it to synchronize nearly everything, but the biggest benefit is, that I can now automatically sync my workspace directory between my Computer, my Laptop and any device Seafile supports. As long as I’m connected to the Internet, my changes are automatically pushed to the server.
This is my current solution to the sync problem. But I’m thinking about switching fully or in part to syncthing. With syncthing the devices can sync directly over the fast local network. They would only use the webserver if no other device is connected to the same network. This method is especially good for people that have a bad Internet connection. Here I would think of a setup like this: A webserver, a server in the local network (like a Raspberry Pi) and the clients. If one client shares a huge amount of data, it would be synced to the local server very fast. Then you don’t need to keep your machine running until the upload finishes, the local server will do it for you.
Of course it’s up to you what you want to use. And for many people the existing commercial cloud services maybe a better solution, but not for me.

[DE] Warum ich zu Linux wechsle

Endlich steht meine Entscheidung fest, nach mehreren Jahren überlegen wechsle ich zu Linux und kehre Windows (10) den Rücken. Es war nicht leicht, jedoch hat Microsoft dank Windows 10 und dem Upgradezwang für Windows 7 – 8.1 diese Entscheidung quasi für mich getroffen.

Man kann mich, was Datenschutz angeht, teilweise schon paranoid nennen. Dementsprechend war ich von Anfang an skeptisch gegenüber der nicht abschaltbaren Übermittlung von Daten an Microsoft. Die „Wahl“ zwischen „Vollständig“ und „Einfach“ ist meiner Meinung nach keine wirkliche Wahl. Nirgends steht hier genau, welche Daten Windows 10 eigentlich an Microsoft sendet. Zählen die Bilder die ich anschaue, Texte die ich schreibe, welche Tasten ich zu welchem Zeitpunkt drücke, etc. auch zu den Nutzungsstatistiken? Einen kleinen Vorgeschmack, was an Daten anfällt, bekommen wir durch einen Blogeintrag von Microsoft: . Hier präsentiert Microsoft stolz, wie viele Minuten die Nutzer bereits mit Edge im Internet verbracht haben und wie viele Bilder mit der Windows Photo-app bereits angeschaut wurden – und das sind nur die Daten, die Veröffentlicht wurden…

Ich sehe meinen Computer, den ich selbst gekauft habe und in meiner Wohnung steht, als mein persönliches Hoheitsgebiet an. Wenn ich ein Programm installiere, dass alles auf meinem Computer ausspäht, dann ist das meine Entscheidung, ob ich es in kauf nehme, dass es das tut, oder eben nicht. Doch spätestens mit Windows 10 hat man keine Wahl mehr. Der Benutzer hat nicht einmal mehr die Wahl zu sagen, nein ich installiere keine Updates. Vordergründig sind die Argumente von Microsoft plausibel, man kann so schnell alle Computer updaten, wenn Sicherheitslücken behoben wurden. Was die meisten hierbei aber vergessen ist die Tatsache, dass hierdurch eine gravierende Sicherheitslücke geschaffen wurde. Microsoft, oder jeder der sich Zugang verschaffen kann, hat die Möglichkeit, beliebige Software auf jedem vorhandenen Windows 10 Computer zu installieren. Genau so eine Funktion wird in vielen Trojanern und Viren eingebaut, um die Kontrolle über einen Computer zu übernehmen und für eigene Zwecke zu verwenden. Man kann jetzt natürlich sagen, Linux bietet auch automatische Updates an, die man missbrauchen könnte. Damit hat man auch nicht unrecht, nur muss ich als Benutzer selbst das Update ausführen, es kann mir also niemand vorschreiben, dass ich updaten muss. Zudem sind alle Quellen, von denen die Updates bezogen werden, öffentlich einsehbar. Es hat also jeder zumindest die Möglichkeit, einen Missbrauch festzustellen.

Jetzt gehen wir mal davon aus, dass eine Staatliche Organisation wie z.B. die NSA zu Microsoft kommt und sie zwingt, über das Update-System ein Spionageprogramm auf jedem Windows Computer zu installieren. Das ist der Zeitpunkt bei dem viele jetzt sagen: „Ich habe ja nichts zu verbergen“. Das kann gut sein – ich persönlich habe auch nichts zu verbergen – nur würde ich es mir deswegen noch lange nicht gefallen lassen, dass irgendjemand Kameras in meiner Wohnung platziert. Auch wenn er nur schauen will, ob ich auch wirklich brav bin. Aber das Thema Datenschutz scheint heutzutage nur noch wenige Menschen zu interessieren, da ist es wichtiger, dass jeder weiß, was, wo und mit wem ich gerade esse. Aber das ist ein (etwas) anderes Thema.

Um die negativen Punkte, die ich bis jetzt herausgefunden habe abzuschließen, fällt mir noch ein Vergleich ein, den ein Bekannter vor kurzem gemacht hat. „Windows 10 ist wie die kostenlosen SIM-Karten aus dem Film ‚Kingsman: The Secret Service‘ “

Auch wenn ich das gerne behaupten würde, aber auch Linux ist bei weitem nicht Perfekt – aber was ist schon Perfekt. Ich verwende momentan Kubuntu und KDE Neon. Die Systeme sind leider nicht so „Bugfrei“ wie Windows das ist, jedoch muss man auch bedenken, dass hier keine komplette Industrie dahinter steht. Treiber für Hardware müssen meistens von Entwicklern außerhalb der Herstellerfirma in ihrer Freizeit geschrieben werden. Genauso wird die meiste Software von Entwicklern in ihrer Freizeit geschrieben. Dementsprechend funktionieren viele Geräte unter Windows besser als unter Linux. Es gibt jedoch auch viele Beispiele die das Gegenteil aufzeigen.

Ich muss zugeben, ich bin auch noch nicht komplett auf Linux umgestiegen und habe auf meinem Computer auch  immer noch Windows 7. Für meine Arbeit brauche ich das momentan noch, da ich hier Plugins für Windowsprogramme entwickle. Auch die Grafikleistung, die man beispielsweise zum Spielen benötigt, ist unter Windows noch deutlich besser wie unter Linux. Hier habe ich jedoch die Hoffnung, dass sich das durch AMDs neue Treiberpolitik und Valve bald ändern wird.

Für mich gibt es momentan also mehr Gründe Windows (10) nicht zu benutzen, als Linux nicht zu benutzen. Linux hat aber zudem eine Eigenschaft, die es stark von Windows abhebt: es ist OpenSource. Wenn man die Geschichte betrachtet hat der Grundgedanke von OpenSource uns erst soweit gebracht, wie wir jetzt sind. Ohne OpenSource würde es z.B.  das www oder E-Mail in seiner heutigen Form nicht geben. Schon früher hat der Mensch die Arbeitsweise seines Nachbarn kopiert, wenn er dadurch seine Arbeit schneller, effizienter und besser ausführen konnte; denn kopieren und verbessern heißt Fortschritt.

[EN] Installing Redmine 3.0 on clean Ubuntu 14.04

In this tutorial we will install Redmine on a clean installation of Ubuntu server 14.04 with an Apache server and MySql. Redmine wil be reachable under the subdomain

Here Redmine will be installed to  /var/www/vhosts/redmine . I use unzip  to unpack the archive. The placeholder for the username you’re logged into the system is  $sysUser$ .

Step 1 – Installing required software

First we need to update our packages. If you encounter any problems later on try to fix them by updating your packages again.

Now install apache2 and mysql:

While installing mysql-server you will be asked for a MySql root password to set.

Step 2 – Database creation

To create the database log in as root user with the password you set earlier.

The following MySql queries create the database and the user to access this database. Be sure you have my_password replaced with an other password (not the root password) before executing.

To exit  mysql simply type  exit and execute.

Step 3 – Downloading Redmine

Now switch in your vhosts directory download Redmine and unzip it. If you want you can use the .tar.gz file with the tar command as well.

Step 4 – Database configuration

We need to alter the file /var/www/vhosts/redmine/config/database.yml.example  and save it as  database.yml . Replace my_password with the password set in the MySql query before.

If your MySql server is running on another Port (eg. 3344) you can use the following config:

Step 5 – Installing ruby

First we have to remove the old version of ruby.

Execute the following command (not as root user) with the ‚\‘ at the beginning. It will install ruby at your system, usable for every user in the group rvm. The installation folder is  /usr/local/rvm .

In my case the first run failed because of a missing signature. The command to install this signature will be displayed in the error-message. In my case it was this:

Then rerun the command to install ruby.

After some time ruby is installed with rails. Now the users $sysUser$ and www-data  need to be added to the group  rvm .

After a relogin the change should be applyed. You have to switch folders back t your Redmine folder.

If you encounter any problems with mysql during installation execute  sudo apt-get install libmysqlclient-dev.  Then execute the command again.

Step 6 – Configuring Redmine with ruby

Generate an secret cookie token:

Create the database structure:

Insert the default configuration:

Start the webrick server to test if everything is ok. You can access the webrick server from localhost only, so its ok if it throws no errors while starting. Then shutdown the webrick server.

 Step 7 – Installing passenger

Because the repository version of passenger will install the old ruby from the repository again, we have to install it via gem.

Now we have to install some other packages, required for passenger integration in apache2:

Then execute the following commands to install the passenger module to apache2.


Alter the file /etc/apache2/mods-avaiable/passenger.load  to this:

And the file /etc/apache2/mods-available/passenger.conf  to this:

Now enable the passenger mod:

Step 8 – Configuring Apache

To reach redmine under we have to create a new file in /etc/apache2/sites-avaiable . I called the file .

To activate the site execute  a2ensite and rename the file /var/www/vhosts/redmine/public/dispatch.fcgi.example  to dispatch.fcgi . Now restart apache2  via  sudo service apache2 restart .

Everything should be up an running. If you have any suggestions to improve the installation process comment below.