Flylib.com

Books Software

 
 
 

Section 3.3. Getting Help Online


3.3. Getting Help Online

In addition to the Trolltech Online Documentation, [4] which includes links to API docs as well as FAQs, [5] there are many online resources available to you.

[4] http://doc.trolltech.com

[5] http://www.trolltech.com/developer/faqs/

  1. The Qt Interest Mailing List [6] provides a developer community and searchable archives. Searching on a class you are trying to use, or an error message you do not understand, will often give you useful results.

    [6] http://lists.trolltech.com/qt-interest/

  2. QtCentre, [7] a Web-based online community.

    [7] http://www.qtcentre.org/

  3. If it's not directly related to Qt, and the error message is short and rare enough, Google might even come up with interesting hits.

  4. There is also a #qt irc channel on irc.freenode.net .



3.4. Style Guidelines and Naming Conventions

C++ is a powerful language that supports many different programming styles. The coding style used in most Qt programs is not "pure" C++. Instead, it uses combination of macros and preprocessor trickery to achieve a higher-level dynamic language that more closely resembles Java or Python than C++. In fact, to take full advantage of Qt's power and simplicity, we tend to abandon the Standard Library entirely.

We find there are certain aspects to "Qt programming style" that are worth emulating, and they are summarized here. For a more complete guide, see "Designing Qt-Style C++ APIs," by Matthias Ettrich, published by Trolltech.

  • Class names begin with a capital letter: class Customer

  • Function names begin with a lowercase letter.

  • Although permitted by the compiler, periods, underscores, dashes, and funny characters should be avoided whenever possible (except where noted below).

  • Multi-word names have subsequent words capitalized: class FileTagger void getStudentInfo() for example.

  • Constants should be in CAPS .

  • Each class name should be a noun or a noun phrase: class LargeFurryMammal; for example.

  • Each function name should be a verb or a verb phrase: processBookOrder(); for example.

  • Each bool variable name should produce a reasonable approximation of a sentence when used in an if() statement: bool isQualified; for example.

For data members , we use a common prefix.

  • Member name: m_Color, m_Width (prepend lowercase m_)

  • static data members: sm_Singleton, sm_ObjCount

For each attribute, we have naming conventions for their corresponding getters/setters.

  • Non-boolean getters: color () or getColor() [8]

    [8] The latter is Java style, the former is Qt style. Both conventions are widely used. Try to be consistent in your code.

  • Boolean getters: isChecked() or isValid()

  • Setter: setColor(const Color& newColor);

A consistent naming convention greatly improves the readability and maintainability of a program.



3.5. The Qt Core Module

Qt 4 is a library consisting of smaller libraries, or modules . The most popular ones are

  • core including QObject , QThread , QFile , and so forth

  • gui all classes derived from QWidget , and some related classes

  • xml for parsing and serializing XML

  • sql for communicating with SQL databases

  • net for communicating data between hosts on specific protocols (http, tcp, udp)

Except for core, modules need to be "enabled" in qmake project files in order to be used. For example:

QT += xml  # to use the xml module
QT += gui  # to use QWidgets
QT += sql  # to use SQL module


The following section will introduce some of the core library classes.