Qt3 tutorial pdf




















New to Qt? Don't know how to start? Then this wiki page is for you! It is a step by step tutorial that presents all specificities and features of Qt. Want to learn more? Qt pronounced as "cute", not "cu-tee" is a cross-platform framework that is usually used as a graphical toolkit, although it is also very helpful in creating CLI applications.

Ports for Android Necessitas and iOS are also in development. They can be built from source, or better, be downloaded as an SDK from the download page. You might choose not to install them by selecting "custom install". Be sure to keep these packages. NB : On linux, it is better to use the packages that your distribution provides.

Qt Creator should be available in nearly all distributions, and installing it should install all dependencies, like libraries, compilers, and developement headers. It provides a doc browser and the "designer", which makes creation of windows easier, all wrapped in a well-designed user interface. It's also one of the fastest IDE's available.

Let's start by creating our first project. Follow the wizard, and after selecting the project folder and name, and select the version of Qt to use, you should land on this page.

This is the project file extension. Qt uses a command line tool that parses these project files in order to generate "makefiles", files that are used by compilers to build an application. This tool is called qmake. But, we shouldn't bother too much about qmake, since Qt Creator will do the job for us. Let's now add the entry point of our application. Follow the wizard once again, naming the file "main", and you are done. You will notice that in the project file, a new line has been added automatically by Qt Creator :.

QApplication is a very important class. It takes care of input arguments, but also a lot of other things, and most notably, the event loop. The event loop is a loop that waits for user input in GUI applications. Let's compile this application. By clicking on the green arrow on the bottom left, Qt Creator will compile and execute it. And what happened? The application seems to be launched and not responding. That is actually normal. The event loop is running and waiting for events, like mouse clicks on a GUI, but we did not provide any event to be processed, so it will run indefinitely.

Qt Creator does the job of invoking the build system for us, but it might be interesting to know how Qt programs are compiled. For small programs, it is easy to compile everything by hand, creating objects files, then linking them.

But for bigger projects, the command line easily becomes hard to write. If you are familiar with Linux, you may know that all the programs are compiled using a makefile that describes all these command lines to execute. But for some projects, even writing a makefile can become tedious. With a simple syntax, it produces the makefile that is used to compile a Qt program.

But that is not its only goal. You will see this in another chapter. This chapter gives an overview of the widgets modules. It will cover widgets properties, the inheritance scheme that is used in widgets, and also the parenting system. Qt objects have a lot of attributes that can be modified using getters and setters. In Qt, if an attribute is called foo , the associated getter and setter will have these signatures. In fact, Qt extends this system of attributes and getters and setters to something called property.

A property is a value of any type that can be accessed, be modified or constant, and can notify a change. The property system is useful, especially in the third part QML. For now, we will use "attribute" or "property" to do the same thing. We can also change the font. In Qt, a font is represented with the QFont class. The documentation provides a lot of information. We are especially concerned here with one of the constructors of QFont. The following snippet will change the font to Courier.

You can try other parameters of QFont's constructor to reproduce the button that is represented in the first picture in this chapter. Setting an icon is not very difficult either. An icon is represented with the QIcon class.

And you can create an icon provided that it has an absolute or relative path in the filesystem. I recommend providing the absolute path in this example. But for deployment considerations, you might use the relative path, or better, the resource system. On Linux, and some other OS's, there is a convenient way to set an icon from an icon theme. It can be done by using the static method:. For example, in the screenshot at the beginning of this chapter, the smiley comes from the Oxygen KDE icon theme and was set by:.

Qt widely uses inheritance, especially in the Widgets module. The following graph shows some of these inheritances:. QObject is the most basic class in Qt. Most of classes in Qt inherit from this class. QObject provides some very powerful capabilities like:. Widgets are able to respond to events and use parenting system and signals and slots mechanism.

All widgets inherit from QObject. The most basic widget is the QWidget. QWidget contains most properties that are used to describe a window, or a widget, like position and size, mouse cursor, tooltips, etc.

Client Storage Chapter - Describes the basics of storing information on the client side. It is divided into four chapters. We recommend that you read the qmake user guide after completing this tutorial. Qt Linguist - A guided tour through the translations process, explaining the tools provided for developers, translators and release managers. Online Learning Materials These online materials provide further tutorials and developer presentations. Many of their learning content are hosted online.

The examples are part of the Qt packages. Visit the Downloads page for more information. Open and run examples within Qt Creator's Welcome mode. Most of the examples run on various platforms and to search for platform-specific examples, type the platform name or any keywords in the search field. For example, typing Android in the search field lists the examples that are fully compatible with Android.



0コメント

  • 1000 / 1000