ClearableLineEdit.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package MemoryX::gui-plugins::SceneEditor
19  * @date 2015
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 /* Qt-headers */
27 #include <QLineEdit>
28 #include <QToolButton>
29 #include <QPointer>
30 
31 namespace gui
32 {
33 
34  /**
35  * This class is a custom QLineEdit which provides a button to clear the text of the line edit.
36  * Inherited from QLineEdit.
37  *
38  * @see Qt::QLineEdit
39  *
40  */
41  class ClearableLineEdit : public QLineEdit
42  {
43  Q_OBJECT
44  public:
45 
46  /**
47  * Constructor.
48  * Creates an instance of ClearableLineEdit by a given QWidget as parent.
49  * The <i>parent</i> argument is sent to the QWidget constructor.
50  * If no parent is given, the default parent is 0.
51  *
52  * @param parent parent widget
53  *
54  */
55  explicit ClearableLineEdit(QWidget* parent = 0);
56 
57  /**
58  * Destructor.
59  * Destroys the clearable line edit.
60  *
61  */
62  ~ClearableLineEdit() override;
63 
64  protected:
65  /**
66  * This event handler is implemented to receive widget resize events which are passed in the <i>event</i> parameter.
67  * When <i>resizeEvent()</i> is called, the widget already has its new geometry.
68  * The old size is accessible through Qt::QResizeEvent:oldSize().
69  *
70  * @param Qt::QResizeEvent
71  * @see Qt::QResizeEvent
72  * @see Qt::QWidget:resizeEvent();
73  *
74  */
75  void resizeEvent(QResizeEvent*) override;
76 
77  private:
78  QPointer<QToolButton> clearButton;
79 
80  private Q_SLOTS:
81  void updateClearButton(const QString& text);
82 
83  };
84 }
85 
gui::ClearableLineEdit::~ClearableLineEdit
~ClearableLineEdit() override
Destructor.
Definition: ClearableLineEdit.cpp:62
gui::ClearableLineEdit
This class is a custom QLineEdit which provides a button to clear the text of the line edit.
Definition: ClearableLineEdit.h:41
gui::ClearableLineEdit::resizeEvent
void resizeEvent(QResizeEvent *) override
This event handler is implemented to receive widget resize events which are passed in the event param...
Definition: ClearableLineEdit.cpp:48
gui::ClearableLineEdit::ClearableLineEdit
ClearableLineEdit(QWidget *parent=0)
Constructor.
Definition: ClearableLineEdit.cpp:29