Doc - more of part 4, including a screenshot and lots of docs

RevBy:    TrustMe
This commit is contained in:
Kavindra Devi Palaraja
2009-06-05 17:57:47 +02:00
parent 0912e70469
commit dcda330906
6 changed files with 148 additions and 99 deletions

View File

@@ -575,6 +575,15 @@
\section1 Placing Widgets on the Form
To edit and remove contacts, we need two push buttons. Drag them and name
them accordingly. Their \c objectName properties should be \c editButton
and \c removeButton, respectively. The quickest way to place these two
buttons into our existing layout, is to simply drag and drop them. Use the
screenshot below as a guide:
\image addressbook-tutorial-part4-drop-in-gridlayout.png
\section1 The AddressBook Class
We update the header file to contain the \c Mode enum:
@@ -586,6 +595,26 @@
\snippet examples/addressbook-sdk/part4/addressbook.h slot definition
In order to switch between modes, we introduce the \c updateInterface()
function to control the enabling and disabling of all push buttons. We also
add two new push buttons, \c editButton and \c removeButton, for the edit
and remove functions mentioned earlier.
\snippet examples/addressbook-sdk/part4/adressbook.h updateInterface
\dots
\snippet examples/addressbook-sdk/part4/addressbook.h members
Lastly, we declare \c currentMode to keep track of the enum's current mode.
\snippet examples/addressbook-sdk/part4/addressbook.h current mode
Let's begin by implementing the mode-changing features of the address book
application. The \c editButton and \c removeButton are extracted and
disabled by default, as the address book starts up with zero contacts in
memory.
*/
/*!

View File

@@ -1,4 +1,3 @@
//! [class definition]
#ifndef ADDRESSBOOK_H
#define ADDRESSBOOK_H
@@ -50,4 +49,3 @@ private:
};
#endif // ADDRESSBOOK_H
//! [class definition]

View File

@@ -31,7 +31,15 @@ AddressBook::AddressBook(QWidget *parent)
previousButton = new QPushButton;
previousButton = ui->previousButton;
nextButton->setEnabled(false);
previousButton->setEnabled(false);
editButton = new QPushButton;
editButton = ui->editButton;
editButton->setEnabled(false);
removeButton = new QPushButton;
removeButton = ui->removeButton;
removeButton->setEnabled(false);
connect(addButton, SIGNAL(clicked()), this,
SLOT(addContact()));

View File

@@ -1,4 +1,3 @@
//! [class definition]
#ifndef ADDRESSBOOK_H
#define ADDRESSBOOK_H
@@ -39,20 +38,27 @@ public slots:
private:
Ui::AddressBook *ui;
//! [updateInterface]
void updateInterface(Mode mode);
//! [updateInterface]
QPushButton *addButton;
QPushButton *submitButton;
QPushButton *cancelButton;
//! [members]
QPushButton *editButton;
QPushButton *removeButton;
//! [members]
QPushButton *nextButton;
QPushButton *previousButton;
//! [members]
QLineEdit *nameLine;
QTextEdit *addressText;
QMap<QString, QString> contacts;
QString oldName;
QString oldAddress;
//! [current mode]
Mode currentMode;
//! [current mode]
};
#endif // ADDRESSBOOK_H
//! [class definition]

View File

@@ -6,104 +6,112 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
<width>472</width>
<height>294</height>
</rect>
</property>
<property name="windowTitle">
<string>AddressBook</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>413</width>
<height>260</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameLine"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="addressLabel">
<property name="text">
<string>Address:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QTextEdit" name="addressText"/>
</item>
<item row="1" column="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="submitButton">
<property name="text">
<string>Submit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="nextButton">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="previousButton">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameLine"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="addressLabel">
<property name="text">
<string>Address:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QTextEdit" name="addressText"/>
</item>
<item row="1" column="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="submitButton">
<property name="text">
<string>Submit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editButton">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="nextButton">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="previousButton">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB