Home > Articles > Programming > User Interface (UI)

  • Print
  • + Share This
Like this article? We recommend

Your Own Experiments

It doesn't take much to start your own Qt-based coding experiments. While Qt is proprietary, several personal use or evaluation licenses encourage such trials. All that's required is to download the appropriate library, unpack it (you don't even need the full installation that the supplied INSTALL describes), and write your own example.c based on Tutorial 1

#include <qapplication.h>
#include <qpushbutton.h>

int main(int argc, char **argv)
  QApplication my_application(argc, argv);

  QPushButton my_button("Push me", 0);
  my_button.resize(100, 30);

  return my_application.exec();

Then generate an executable:

g++ -I/usr/local/qt/include -L/usr/local/qt/lib    -o example example.c -lqt

At this point, you should be able to launch your own tiny GUI program, example (see Figure 1). The online Qt tutorials do an excellent job of explaining all the Qt features manifested in even this simple example, including resizing and interaction with window managers.

Figure 1Figure 1 Creating a simple GUI program is easy with Qt.

  • + Share This
  • 🔖 Save To Your Account