forked from qt-creator/qt-creator
Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
This commit is contained in:
@@ -133,7 +133,7 @@
|
|||||||
Now we have all the files we need, let's move on to designing the user
|
Now we have all the files we need, let's move on to designing the user
|
||||||
interface.
|
interface.
|
||||||
|
|
||||||
\section1 Placing the Widgets on the Form
|
\section1 Placing Widgets on the Form
|
||||||
|
|
||||||
In the \gui{Project Sidebar}, double-click on the \c{addressbook.ui} file.
|
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 plugin will be launched, allowing you to design your program's user
|
||||||
@@ -194,6 +194,13 @@
|
|||||||
|
|
||||||
\snippet examples/addressbook-sdk/part1/main.cpp main function
|
\snippet examples/addressbook-sdk/part1/main.cpp main function
|
||||||
|
|
||||||
|
The code constructs a new \c AddressBook widget on the heap using the
|
||||||
|
\c new keyword and invokes its \l{QWidget::}{show()} function to display
|
||||||
|
it. However, the widget will not be shown until the application's event
|
||||||
|
loop is started, by calling the application's \l{QApplication::}{exec()}
|
||||||
|
function. Finally, the result returned by \l{QApplication::}{exec()} is
|
||||||
|
used as the return value from the \c main() function.
|
||||||
|
|
||||||
|
|
||||||
\section1 Qt Programming - Subclassing
|
\section1 Qt Programming - Subclassing
|
||||||
|
|
||||||
@@ -220,3 +227,28 @@
|
|||||||
address book is needed.
|
address book is needed.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\page tutorials-addressbook-sdk-part2.html
|
||||||
|
\previouspage Address Book 1 - Designing the User Interface
|
||||||
|
\contentspage {Address Book Tutorial}{Contents}
|
||||||
|
\nextpage \l{examples/addressbook-sdk/part3}{Chapter 3}
|
||||||
|
\example examples/addressbook-sdk/part2
|
||||||
|
\title Address Book 2 - Adding Addresses
|
||||||
|
|
||||||
|
The next step to creating our basic address book application is to allow a
|
||||||
|
little bit of user interaction.
|
||||||
|
|
||||||
|
### \image addressbook-tutorial-part2-add-contact.png
|
||||||
|
|
||||||
|
We will provide a push button that the user can click to add a new contact.
|
||||||
|
Also, some form of data structure is needed to store these contacts in an
|
||||||
|
organized way.
|
||||||
|
|
||||||
|
|
||||||
|
\section1 Placing Widgets on the Form
|
||||||
|
|
||||||
|
Now that we have the labels and input fields set up, we add push buttons to
|
||||||
|
complete the process of adding a contact.
|
||||||
|
|
||||||
|
*/
|
||||||
|
15
doc/examples/addressbook-sdk/part2/addressbook.cpp
Normal file
15
doc/examples/addressbook-sdk/part2/addressbook.cpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
//! [class implementation]
|
||||||
|
#include "addressbook.h"
|
||||||
|
#include "ui_addressbook.h"
|
||||||
|
|
||||||
|
AddressBook::AddressBook(QWidget *parent)
|
||||||
|
: QWidget(parent), ui(new Ui::AddressBookClass)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
AddressBook::~AddressBook()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
//! [class implementation]
|
25
doc/examples/addressbook-sdk/part2/addressbook.h
Normal file
25
doc/examples/addressbook-sdk/part2/addressbook.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
//! [class definition]
|
||||||
|
#ifndef ADDRESSBOOK_H
|
||||||
|
#define ADDRESSBOOK_H
|
||||||
|
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class AddressBookClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AddressBook : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
AddressBook(QWidget *parent = 0);
|
||||||
|
~AddressBook();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::AddressBookClass *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ADDRESSBOOK_H
|
||||||
|
//! [class definition]
|
49
doc/examples/addressbook-sdk/part2/addressbook.ui
Normal file
49
doc/examples/addressbook-sdk/part2/addressbook.ui
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AddressBookClass</class>
|
||||||
|
<widget class="QWidget" name="AddressBookClass">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>356</width>
|
||||||
|
<height>261</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>AddressBook</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="nameEdit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="addressEdit">
|
||||||
|
<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="textEdit"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
12
doc/examples/addressbook-sdk/part2/main.cpp
Normal file
12
doc/examples/addressbook-sdk/part2/main.cpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
//! [main function]
|
||||||
|
#include <QtGui/QApplication>
|
||||||
|
#include "addressbook.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
AddressBook w;
|
||||||
|
w.show();
|
||||||
|
return a.exec();
|
||||||
|
}
|
||||||
|
//! [main function]
|
16
doc/examples/addressbook-sdk/part2/part2.pro
Normal file
16
doc/examples/addressbook-sdk/part2/part2.pro
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2009-03-06T12:30:35
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
TARGET = addressbook
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES += main.cpp\
|
||||||
|
addressbook.cpp
|
||||||
|
|
||||||
|
HEADERS += addressbook.h
|
||||||
|
|
||||||
|
FORMS += addressbook.ui
|
Reference in New Issue
Block a user