Application Development in Qt

In Qt, basically 5 types of applications can be developed. Depending on your purpose, you choose the one and all the environment for developing the application is provided by the framework. They are namely:

  • Qt Widgets Application
  • <li>Qt Quick Application</li>
    <li>Qt Quick UI Application</li>
    <li>HTML5 Application</li>
    <li>Qt Console Application</li>

In this post, I will be telling you about the first three.

Qt Widgets Application
Widgets form the basic building up entity of a user interface application. Talking in context to any CAD software’s UI, you see a button, a menubar, anything on the user interface, that is a widget. You are able to access the functionalities, the services provided by the software by means of these. These all are widgets.

When you choose to develop this type of application, whatever you do is in C++. This is what the framework provides by default. The thing would be different if you add some QML files in the resources folder of the app. Will be telling you about QML ahead. In this app, we have a UI file by default which is created in design mode of QtCreator. UI files are centred to widget based approach only.

Huh, now coming to the two modes of QtCreator. They are: edit mode and design mode. In edit mode, you do the coding part while in design mode, you have the actual look of the window. You can select any component say a toolbutton or any other component and place it on the window at the place where you want. The associated functionality of the component added in design mode is implemented by means of slots. Well, that is a different concept. Signal-slot mechanism is the soul behind the working of UI apps in Qt. Will be telling some other time.

Just manipulate the code in edit mode and see the components you added in action.

Qt Quick UI Application
This application is developed using the QML(acronym for Qt Modeling Language). It is Javascript based language and centred mainly for user interfaces’ applications. In this type of application, only QML is in action. QML is part of Qt Quick which is a UI-creation kit. You can work in edit mode or design mode here also. Well, working in design mode makes things so easy. The functioning is added in edit mode just like QtWidgets application.

Qt Quick Application
This application is a combination of the previous two. You can have C++ and QML both working in the same project. The rest things are the same as the previous two types of applications.

Well, this was all for someone entirely dummy in application development in Qt, covering some simple things yet important.

Will it lead somewhere?

Though I did not explain well in my previous post about integration of QML and C++ and maybe would have seemed beating around the bush, I got a way to use objects created in QML to be used and manipulated via C++. It is not tough. -_- Sometimes, this teasing brain really does not think of the basic logics.

The documentation is prodigious. All you need is to explore. The exact page to look for was pointed out by "LBV_User" on the qt IRC.

Basically, the QML files can be uploaded in cpp using QQmlComponent or by using QQuickView. I created a rectangle object in qml. Many of you would not have seen QML code. Here is the code to create a recatngle.
import QtQuick 2.0
Item {
width: 100; height: 100
Rectangle {
anchors.fill: parent
objectName: "rect"
}
}

Wasn’t that so simple? The above code won’t even need explanations. That’s the beauty of QML. 😀 Even if you do not know what to go where in code in QtCreator, just use "Ctrl+Space" and you will be able to figure out what possible things you can have for a given object.

Coming to integrate it in C++ and modify it, my main file looks like this. So I got a qml file as well as a c++ file manipulating it. The properties of the rectangle that were set in qml file are changed in cpp file.

This was not at all troubling. 🙁 It maybe a baby step to the imminent implementation to be done in the LCv3 UI. Yesterday, I had it working other way around. Today, I have what is required. I was uncertain and will be till I get my hands on it escorting to implementation where it is actually required. Stuck with the question "Will it lead somewhere?".

I will be diving into the workflow of LCv3 tomorrow. Hoping to make significant progress step by step!