forked from qt-creator/qt-creator
139 lines
6.7 KiB
Diff
139 lines
6.7 KiB
Diff
diff --git a/doc/addressbook-sdk.qdoc b/doc/addressbook-sdk.qdoc
|
|
index 0441666..7012ea6 100644
|
|
--- a/doc/addressbook-sdk.qdoc
|
|
+++ b/doc/addressbook-sdk.qdoc
|
|
@@ -139,7 +139,7 @@
|
|
\section1 Placing Widgets on The Form
|
|
|
|
In the \gui{Project Sidebar}, double-click on the \c{addressbook.ui} file.
|
|
- The \QD plugin will be launched, allowing you to design your program's user
|
|
+ The \QD form editor will be launched, allowing you to design your program's user
|
|
interface.
|
|
|
|
We require two \l{QLabel}s to label the input fields as well as a QLineEdit
|
|
@@ -156,6 +156,7 @@
|
|
diagram below shows the layout cells and the position of our widgets. Place
|
|
your widgets accordingly and save the form by choosing
|
|
\gui{File | Save} or using the \key{Ctrl+S} shortcut.
|
|
+ (We have to actually layout the widgets in a grid layout, this step seems to be missing to me?)
|
|
|
|
\image addressbook-tutorial-part1-labeled-screenshot.png
|
|
|
|
@@ -311,7 +312,7 @@
|
|
\snippet examples/addressbook-sdk/part2/addressbook.h slot definition
|
|
|
|
Since the \c AddressBook class is a subclass of QWidget, Qt Creator
|
|
- includes QWidget in the hedaer file.
|
|
+ includes QWidget in the header file.
|
|
|
|
\snippet examples/addressbook-sdk/part2/addressbook.h include
|
|
|
|
@@ -323,7 +324,7 @@
|
|
\snippet examples/addressbook-sdk/part2/addressbook.h members
|
|
|
|
We also declare two private QString objects, \c oldName and \c oldAddress.
|
|
- These objects are needed to hold the name and address of hte contact that
|
|
+ These objects are needed to hold the name and address of the contact that
|
|
was last displayed, before the user clicked \gui Add. So, when the user
|
|
clicks \gui Cancel, we can revert to displaying the details of the last
|
|
contact.
|
|
@@ -499,7 +500,7 @@
|
|
|
|
\snippet examples/addressbook-sdk/part3/addressbook.cpp enable navigation
|
|
|
|
- We also include these lins of code in the \c cancel() function.
|
|
+ We also include these lines of code in the \c cancel() function.
|
|
|
|
Recall that we intend to emulate a circularly-linked list with our QMap
|
|
object, \c contacts. So in the \c next() function, we obtain an iterator
|
|
@@ -722,11 +723,12 @@
|
|
|
|
#image
|
|
|
|
- We begin by adding a new \c{.ui} file to our project. Right click on your
|
|
+ We begin by adding a new \c{.ui} file and a corresponding class to our project. Right click on your
|
|
project and select \gui{Add New...}. In the \gui{New File} dialog, select
|
|
- \gui{Qt Designer Form}. In the \gui{Qt Designer Form} dialog, select
|
|
- \e{Dialog without buttons}. Name it \c{finddialog.ui} and add it to your
|
|
- project. The \QD plugin within Qt Creator will now display your new form.
|
|
+ \gui{Qt Designer Form Class}. In the \gui{Qt Designer Form Class} dialog, select
|
|
+ \e{Dialog without buttons}. Name the class \c{FindDialog} and add the files it to your
|
|
+ project. Open your new form in the \QD form editor within Qt Creator by
|
|
+ double-clicking on the \c{finddialog.ui} file in the \gui{Project Sidebar}.
|
|
|
|
To replicate the screenshot above, we need a label, a line edit, and a push
|
|
button. Drag these onto your form. Set their text accordingly and name them
|
|
@@ -759,6 +761,9 @@
|
|
\c findContact() function know when the \c FindDialog object has been
|
|
closed. We will explain this logic in further detail when discussing the
|
|
\c findContact() function.
|
|
+ (The above paragraph is not up to date, since clicked() is not connected
|
|
+ to accept(). The description of accept() can move below to the implementation
|
|
+ of findClicked().)
|
|
|
|
\image addressbook-tutorial-part5-signals-and-slots.png
|
|
|
|
@@ -766,17 +771,17 @@
|
|
\gui Find button without entering a contact's name. Then, we set
|
|
\c findText to the search string, extracted from \c lineEdit. After that,
|
|
we clear the contents of \c lineEdit and hide the dialog.
|
|
+ (There is no findText member. The description of accept() should move here, together
|
|
+ with words about reject.)
|
|
|
|
\snippet examples/addressbook-sdk/part5/finddialog.cpp findClicked
|
|
|
|
- The \c findText variable has a public getter function, \c getFindText(),
|
|
- associated with it. Since we only ever set \c findText directly in both
|
|
- the constructor and in hte \c findClicked() function, we do not create a
|
|
- setter function to accompany \c getFindText(). Because \c getFindText() is
|
|
+ The \c text of the find dialog's line edit has a public getter function, \c findText(),
|
|
+ associated with it. Because \c findText() is
|
|
public, classes instantiating and using \c FindDialog can always access the
|
|
search string that the user has entered and accepted.
|
|
|
|
- \snippet examples/addressbook-sdk/part5/finddialog.cpp getFindText
|
|
+ \snippet examples/addressbook-sdk/part5/finddialog.cpp findText
|
|
|
|
|
|
\section1 The AddressBook Class
|
|
@@ -788,23 +793,9 @@
|
|
|
|
So far, all our address book features have a QPushButton and a
|
|
corresponding slot. Similarly, for the \gui Find feature, we have
|
|
- \c findButton and \c findContact().
|
|
+ \c {ui->findButton} and \c findContact().
|
|
|
|
\snippet examples/addressbook-sdk/part5/addressbook.h slot definition
|
|
- \dots
|
|
- \snippet examples/addressbook-sdk/part5/addressbook.h private members
|
|
-
|
|
- Lastly, we declare the private variable, \c dialog, which we will use to
|
|
- refer to an instance of \c FindDialog.
|
|
-
|
|
- Once we have instantiated a dialog, we might want to use it more than once;
|
|
- using a private variable allows us to refer to it from more than one place
|
|
- in the class.
|
|
-
|
|
- Within the \c AddressBook class's constructor, we insantiate our private
|
|
- objects, \c findButton and \c dialog:
|
|
-
|
|
- \snippet examples/addressbook-sdk/part5/addressbook.cpp private members
|
|
|
|
Next, we connect the \c{findButton}'s \l{QPushButton::}{clicked()} signal
|
|
to \c findContact().
|
|
@@ -818,10 +809,12 @@
|
|
We start out by displaying the \c FindDialog instance, \c dialog. This is
|
|
when the user enters a contact name to look up. Once the user clicks the
|
|
dialog's \c findButton, the dialog is hidden and the result code is set to
|
|
- QDialog::Accepted. THis ensures that our \c if statement is always true.
|
|
+ either QDialog::Accepted or QDialog::Rejected by the FindDialog's
|
|
+ \c findClicked() method. This ensures that we only search for a contact
|
|
+ if the user typed something in the FindDialog's line edit.
|
|
|
|
We then proceed to extract the search string, which in this case is
|
|
- \c contactName, using \c{FindDialog}'s \c getFindText() function. If the
|
|
+ \c contactName, using \c{FindDialog}'s \c findText() function. If the
|
|
contact exists in our address book, we display it immediately. Otherwise,
|
|
we display the QMessageBox shown below to indicate that their search
|
|
failed.
|