Programming in X

From LQWiki
Jump to navigation Jump to search

Programming in X, due to having several facets and aspects in its operation, can be complex.

Concepts

Some basic X concepts include:

  • The X Window System behaves by acting as a "server" for X-enabled applications, called "clients".
  • X is a network based system - clients can "draw" on another X server across a network.

Libraries

The X Window System is known for providing basic window drawing and graphics management routines, however, X on its own provides no capabilities to draw typical utilities such as scrollbars. Libraries however exist that make use of the basic facilities that X provides to create extra graphical functionality.

Qt

Qt is unique in that it uses the idea of signals and slots. What does this mean? Say you create a button widget to quit you program called "close_btn" you would then connect that signal to close().

connect(quit_btn, SIGNAL(clicked()),
             this, SLOT(close()) );

The above code creates a connection between the button "quit_btn" and the close() slot. Specifically, when the quit_btn emits a clicked() signal the program does the slot close().

There is more to qt than just signals and slots and if you want to find more information, there is a good book called "C++ GUI Programming with Qt4" by Jasmin Blanchette and Mark Summerfield which is part of Bruce Perens' Open Source Series. There are also a number of tutorials on trolltech's, the maker of Qt, site: http://www.trolltech.com/.

XLib