Line by Line Walkthrough class LCDRange : public QWidget
{
public:
LCDRange(QWidget *parent = 0);
};
The LCDRange widget is a widget without any API. It just has a constructor. This sort of widget is not very useful, so we'll add some API later. LCDRange::LCDRange(QWidget *parent)
: QWidget(parent)
{
QLCDNumber *lcd = new QLCDNumber(2);
lcd-...
<P><TT><FONT face=新宋体>lcd</FONT></TT> is a <A href="http://article.cnsilan.com/qtqtopia/qlcdnumber.html"><U>QLCDNumber</U></A>, a widget that displays numbers in an LCD-like fashion. This instance is set up to display two digits. We set the <A href="http://article.cnsilan.com/qtqtopia/qlcdnumber.html#segmentStyle-prop"><U>QLCDNumber::segmentStyle</U></A> property to <A h...
Here we create a new class. Because this class inherits from QWidget, the new class is a widget and may be a top-level window or a child widget (like the QPushButton in the previous chapter).
This class has only one member, a constructor (in addition to the members it inherits from QWidget). The constructor is a standard Qt widget constructor; you should always include a s...
This example shows how to create parent and child widgets.
We'll keep it simple and use just a single parent and a lone child.
Here we simply create a plain widget object. The QWidget class is the base class of all user interface objects. The widget is the atom of the user interface: It receives mouse, keyboard and other events from the window system, and paints a repr...
Having created a window in Chapter 1, we will now go on to make the application quit properly when the user tells it to.
We will also use a font that is more exciting than the default one.
This first program is a simple "Hello world" example. It contains only the bare minimum you need to get a Qt application up and running. The picture below is a screenshot of this program.