qBittorrent
LineEdit Class Referencefinal

#include <lineedit.h>

Inheritance diagram for LineEdit:
Collaboration diagram for LineEdit:

Public Member Functions

 LineEdit (QWidget *parent)
 

Protected Member Functions

void resizeEvent (QResizeEvent *e) override
 
void keyPressEvent (QKeyEvent *event) override
 

Private Attributes

QToolButton * m_searchButton
 

Detailed Description

Definition at line 16 of file lineedit.h.

Constructor & Destructor Documentation

◆ LineEdit()

LineEdit::LineEdit ( QWidget *  parent)

Definition at line 21 of file lineedit.cpp.

22  : QLineEdit(parent)
23 {
24  m_searchButton = new QToolButton(this);
25  m_searchButton->setIcon(UIThemeManager::instance()->getIcon("edit-find"));
26  m_searchButton->setCursor(Qt::ArrowCursor);
27  m_searchButton->setStyleSheet("QToolButton {border: none; padding: 2px;}");
28 
29  // padding between text and widget borders
30  setStyleSheet(QString::fromLatin1("QLineEdit {padding-left: %1px;}").arg(m_searchButton->sizeHint().width()));
31 
32  setClearButtonEnabled(true);
33 
34  const int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
35  setMaximumHeight(std::max(sizeHint().height(), m_searchButton->sizeHint().height()) + frameWidth * 2);
36  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
37 }
QToolButton * m_searchButton
Definition: lineedit.h:28
static UIThemeManager * instance()

References UIThemeManager::instance(), and m_searchButton.

Here is the call graph for this function:

Member Function Documentation

◆ keyPressEvent()

void LineEdit::keyPressEvent ( QKeyEvent *  event)
overrideprotected

Definition at line 48 of file lineedit.cpp.

49 {
50  if ((event->modifiers() == Qt::NoModifier) && (event->key() == Qt::Key_Escape))
51  {
52  clear();
53  }
54  QLineEdit::keyPressEvent(event);
55 }

◆ resizeEvent()

void LineEdit::resizeEvent ( QResizeEvent *  e)
overrideprotected

Definition at line 39 of file lineedit.cpp.

40 {
41  const int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
42  const int xPos = QGuiApplication::isLeftToRight()
43  ? frameWidth
44  : (e->size().width() - m_searchButton->sizeHint().width() - frameWidth);
45  m_searchButton->move(xPos, (e->size().height() - m_searchButton->sizeHint().height()) / 2);
46 }

References nova3.nova2dl::e, and m_searchButton.

Member Data Documentation

◆ m_searchButton

QToolButton* LineEdit::m_searchButton
private

Definition at line 28 of file lineedit.h.

Referenced by LineEdit(), and resizeEvent().


The documentation for this class was generated from the following files: