Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
640278e1
Commit
640278e1
authored
Jun 30, 2009
by
Kavindra Devi Palaraja
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doc - More of Part 5 and some minor changes to part 2 to ensure
that the include statements were explained. Reviewed-By: TrustMe
parent
ca1dd200
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
5 deletions
+50
-5
doc/addressbook-sdk.qdoc
doc/addressbook-sdk.qdoc
+38
-0
doc/examples/addressbook-sdk/part2/addressbook.h
doc/examples/addressbook-sdk/part2/addressbook.h
+2
-3
doc/examples/addressbook-sdk/part5/finddialog.cpp
doc/examples/addressbook-sdk/part5/finddialog.cpp
+4
-0
doc/examples/addressbook-sdk/part5/finddialog.h
doc/examples/addressbook-sdk/part5/finddialog.h
+6
-2
doc/images/addressbook-tutorial-part5-signals-and-slots.png
doc/images/addressbook-tutorial-part5-signals-and-slots.png
+0
-0
No files found.
doc/addressbook-sdk.qdoc
View file @
640278e1
...
...
@@ -315,6 +315,12 @@
\snippet examples/addressbook-sdk/part2/addressbook.h members1
The Qt types used for our private members, e.g., QPushButton, QLineEdit,
QTextEdit, etc., need to be included with the \c include directive, as
shown below:
\snippet examples/addressbook-sdk/part2/addressbook.h include
\note The names, e.g., \c addButton etc., correspond to the name of the
actual object. You can modify them by double-clicking on their names within
\QD's \gui{Object Inspector}.
...
...
@@ -727,6 +733,7 @@
dialog that can prompt the user for a contact's name. Qt provides QDialog,
which we subclass in this chapter, to implement a FindDialog class.
\section1 Designing \c FindDialog
#image
...
...
@@ -743,6 +750,7 @@
in a horizontal layout. Then set a top level layout - either horizontal or
vertical.
\section1 Implementing \c FindDialog
Let's look at \c{FindDialog}'s header file. Here, we need to provide
...
...
@@ -751,8 +759,38 @@
\snippet examples/addressbook-sdk/part5/finddialog.h private members
We define a public function, \c getFindText(), to be used by classes that
instantiate \c FindDialog. This function allows the these classes to obtain
the search string entered by the user. A public slot, \c findClicked(), is
also defined to handle the search string when the user clicks the \gui Find
button.
\snippet examples/addressbook-sdk/part5/finddialog.h getFindText
\dots
\snippet examples/addressbook-sdk/part5/finddialog.h findClicked
Now, lets look at our constructor in the \c{finddialog.cpp} file. Here, we
set up the private variables, \c lineEdit, \c findButton, and \c findText.
\snippet examples/addressbook-sdk/part5/finddialog.cpp constructor
We connect our signals to their respective slots. Notice that
\c{findButton}'s \l{QPushButton:}{clicked()} signal is connected to
\c findClicked() and \l{QDialog::}{accept()}. The \l{QDialog::}{accept()}
slot provided by QDialog hides the dialog and sets the result code to
\l{QDialog::}{Accepted}. We use this function to help \c{AddressBook}'s
\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.
\image addressbook-tutorial-part5-signals-and-slots.png
In \c findClicked(), we validate to ensure that the user did not click the
\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.
\snippet examples/addressbook-sdk/part5/finddialog.cpp findClicked
*/
...
...
doc/examples/addressbook-sdk/part2/addressbook.h
View file @
640278e1
//! [class definition]
#ifndef ADDRESSBOOK_H
#define ADDRESSBOOK_H
//! [include]
#include <QtGui/QWidget>
#include <QtGui/QPushButton>
#include <QtGui/QLineEdit>
#include <QtGui/QTextEdit>
#include <QtGui/QMessageBox>
//! [include]
namespace
Ui
{
...
...
@@ -48,4 +48,3 @@ private:
};
#endif // ADDRESSBOOK_H
//! [class definition]
doc/examples/addressbook-sdk/part5/finddialog.cpp
View file @
640278e1
#include "finddialog.h"
#include "ui_finddialog.h"
//! [constructor]
FindDialog
::
FindDialog
(
QWidget
*
parent
)
:
QDialog
(
parent
),
m_ui
(
new
Ui
::
FindDialog
)
...
...
@@ -18,12 +19,14 @@ FindDialog::FindDialog(QWidget *parent) :
setWindowTItle
(
tr
(
"Find a Contact"
));
}
//! [constructor]
FindDialog
::~
FindDialog
()
{
delete
m_ui
;
}
//! [findClicked]
void
FindDialog
::
findClicked
()
{
QString
text
=
lineEdit
->
text
();
...
...
@@ -38,6 +41,7 @@ void FindDialog::findClicked()
hide
();
}
}
//! [findClicked]
QString
FindDialog
::
getFindText
()
{
...
...
doc/examples/addressbook-sdk/part5/finddialog.h
View file @
640278e1
...
...
@@ -2,8 +2,8 @@
#define FINDDIALOG_H
#include <QtGui/QDialog>
#include <QLineEdit>
#include <QPushButton>
#include <
QtGui/
QLineEdit>
#include <
QtGui/
QPushButton>
namespace
Ui
{
class
FindDialog
;
...
...
@@ -14,10 +14,14 @@ class FindDialog : public QDialog {
public:
FindDialog
(
QWidget
*
parent
=
0
);
~
FindDialog
();
//! [getFindText]
QString
getFindText
();
//! [getFindText]
//! [findClicked]
public
slots
:
void
findClicked
();
//! [findClicked]
//! [private members]
private:
...
...
doc/images/addressbook-tutorial-part5-signals-and-slots.png
0 → 100644
View file @
640278e1
5.41 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment