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 <QPointer>
29#include <QToolButton>
30
31namespace 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 * Constructor.
47 * Creates an instance of ClearableLineEdit by a given QWidget as parent.
48 * The <i>parent</i> argument is sent to the QWidget constructor.
49 * If no parent is given, the default parent is 0.
50 *
51 * @param parent parent widget
52 *
53 */
54 explicit ClearableLineEdit(QWidget* parent = 0);
55
56 /**
57 * Destructor.
58 * Destroys the clearable line edit.
59 *
60 */
61 ~ClearableLineEdit() override;
62
63 protected:
64 /**
65 * This event handler is implemented to receive widget resize events which are passed in the <i>event</i> parameter.
66 * When <i>resizeEvent()</i> is called, the widget already has its new geometry.
67 * The old size is accessible through Qt::QResizeEvent:oldSize().
68 *
69 * @param Qt::QResizeEvent
70 * @see Qt::QResizeEvent
71 * @see Qt::QWidget:resizeEvent();
72 *
73 */
74 void resizeEvent(QResizeEvent*) override;
75
76 private:
77 QPointer<QToolButton> clearButton;
78
79 private Q_SLOTS:
80 void updateClearButton(const QString& text);
81 };
82} // namespace gui
ClearableLineEdit(QWidget *parent=0)
Constructor.
void resizeEvent(QResizeEvent *) override
This event handler is implemented to receive widget resize events which are passed in the event param...
~ClearableLineEdit() override
Destructor.