Showing posts with label Qt Programming. Show all posts
Showing posts with label Qt Programming. Show all posts

Tuesday, May 12, 2015

Laying out Widgets, Creating Spinbox, Slider, Textbox

In the previous tutorial, you have learned how to create a label and a button in Qt. Qt is designed to simplify C++ programmer to create a nice GUI for their application. Therefore, it provides a wide variety of widget classes to create a cool GUI which is divided into groups such as Layouts, Buttons, Item views, Input Widgets, so on and so forth.

Wednesday, April 29, 2015

Basic Qt

Prerequisite
  1. Qt Creator with MinGW or Visual C++

  2. Knowledge of C++

  3. Qt Library
If you have limited experience with C++, please take a look at C++ tutorial before proceeding this tutorial.
The only way to learn a new programming is by starting to write program and play around with it. In this tutorial, we start to write a basic Qt program by using basic functionality of C++ provided by Qt to create a small graphical user interface (GUI). As we have already experienced when we start to learn the programming language, we usually begin with "Hello World". Therefore, we also start with the "hello Qt".

Create HelloQt.cpp

1 #include <QApplication>

2 #include <QLabel>

3 #include <QPushButton>

4 int main(int argc, char *argv[])

5 {

6    QApplication app(argc, argv);

7    QLabel *helloLabel = new QLabel("<font color=blue><b><center>Hello  
      Qt!</center></b></font>");

8    QPushButton *helloButton = new QPushButton("Push me to say Hello");

9    QObject::connect(helloButton, SIGNAL(clicked()), helloLabel,  
      SLOT(show()));

10   helloButton->show();

11   return app.exec();

12   }

Why Qt?

Qt software framework has become a popular cross-platform application framework since its release in 1995. It is widely utilized for developing industrial application software with professional graphical user interfaces (GUIs). With Qt, C++ programmers are easy to build user interface for their applications by dragging and dropping using its GUIs designer. Beside GUIs, Qt is also allowed us to instantiate the class or subclass in order to construct GUIs. Throughout this tutorial, we are going to talk about how to do subclass and instantiate of Qt widgets later. Qt provides main window are generally divided into five sections. In the first section is occupied by the menus followed by toolbars in the second section. 

Qt Creator

Qt creator is the cross platform C++ Integrated Development Environment (IDE) which provides a set of helpful features for assisting developer during the software development process. Those features are listed as the following:
  •     Static code checking and style hinting when typing
  •     Syntax highlighting and code completion
  •    Context sensitive help
  •   Highlighting and folding blocks
  •   Parenthesis matching, and parenthesis selection modes