forked from qt-creator/qt-creator
Doc - More of Part 7
Reviewed-By: TrustMe
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#include "finddialog.h"
|
||||
#include "ui_finddialog.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
FindDialog::FindDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
m_ui(new Ui::FindDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
lineEdit = new QLineEdit;
|
||||
lineEdit = m_ui->lineEdit;
|
||||
|
||||
findButton = new QPushButton;
|
||||
findButton = m_ui->findButton;
|
||||
|
||||
findText = "";
|
||||
|
||||
connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked()));
|
||||
|
||||
setWindowTitle(tr("Find a Contact"));
|
||||
}
|
||||
|
||||
FindDialog::~FindDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void FindDialog::findClicked()
|
||||
{
|
||||
QString text = lineEdit->text();
|
||||
|
||||
if (text.isEmpty()) {
|
||||
QMessageBox::information(this, tr("Empty Field"),
|
||||
tr("Please enter a name."));
|
||||
return;
|
||||
} else {
|
||||
findText = text;
|
||||
lineEdit->clear();
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
||||
QString FindDialog::getFindText()
|
||||
{
|
||||
return findText;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef FINDDIALOG_H
|
||||
#define FINDDIALOG_H
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QPushButton>
|
||||
|
||||
namespace Ui {
|
||||
class FindDialog;
|
||||
}
|
||||
|
||||
class FindDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FindDialog(QWidget *parent = 0);
|
||||
~FindDialog();
|
||||
QString getFindText();
|
||||
|
||||
public slots:
|
||||
void findClicked();
|
||||
|
||||
private:
|
||||
Ui::FindDialog *m_ui;
|
||||
QPushButton *findButton;
|
||||
QLineEdit *lineEdit;
|
||||
QString findText;
|
||||
};
|
||||
|
||||
#endif // FINDDIALOG_H
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FindDialog</class>
|
||||
<widget class="QDialog" name="FindDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>555</width>
|
||||
<height>73</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Enter the name of a contact:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="findButton">
|
||||
<property name="text">
|
||||
<string>Find</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user