Web Analytics Made Easy - Statcounter
Skip to content

Class SBGActionSearchButton#

ClassList > SBGActionSearchButton

This class is a convenience widget that represents a push button associated with a line edit for search. More...

  • #include <SBGActionSearchButton.hpp>

Inherits the following classes: QPushButton

Public Slots#

Type Name
slot void onTextChanged
Handles the text changed signal.

Public Functions#

Type Name
SBGActionSearchButton (QLineEdit * lineEdit, QWidget * parent=nullptr)
Builds an action search button associated with the lineEdit .
virtual ~SBGActionSearchButton ()
Destructor.

Protected Functions#

Type Name
virtual bool event (QEvent * e) override
Handles events.
virtual void mousePressEvent (QMouseEvent * event) override
Handles mouse events.

Detailed Description#

It automatically changes its icon depending on the text changes in the associated line edit, and it on clicking it clears the line edit.

Short name: SBActionSearchButton

Public Slots Documentation#

slot onTextChanged#

Handles the text changed signal.

void SBGActionSearchButton::onTextChanged;

Updates the button icon and tooltip based on the current text of the associated line edit.

This slot is called whenever the text in the associated line edit changes.


Public Functions Documentation#

function SBGActionSearchButton#

Builds an action search button associated with the lineEdit .

SBGActionSearchButton::SBGActionSearchButton (
    QLineEdit * lineEdit,
    QWidget * parent=nullptr
) 

Constructs a search button associated with a line edit.

If you want to add this button to your search line edit, then create it with passing the line edit object and add this button in the same horizontal layout next to the line edit.

// create the search button associated with the search lineEdit
SBGActionSearchButton* lineEditSearchButton = new SBGActionSearchButton(lineEdit);
// add the search button in the same horizontal layout with the line edit
ui.horizontalLayoutLineEditSearch->addWidget(lineEditSearchButton);

Clicking on the clear button will clear the line edit.

Parameters:

  • lineEdit The line edit widget to associate with the button.
  • parent Optional parent widget.

function ~SBGActionSearchButton#

Destructor.

virtual SBGActionSearchButton::~SBGActionSearchButton () 

Destroys the search button and releases its resources.


Protected Functions Documentation#

function event#

Handles events.

virtual bool SBGActionSearchButton::event (
    QEvent * e
) override

Handles generic events for the button, updating the icon on hover when there is text.

This method changes the button icon when the mouse enters or leaves the button while the associated line edit contains text.

Parameters:

  • e The event to be processed.

Returns:

The result of the base class event handling.


function mousePressEvent#

Handles mouse events.

virtual void SBGActionSearchButton::mousePressEvent (
    QMouseEvent * event
) override

Handles mouse press events for the button.

Clears the associated line edit when the button is clicked and sets focus to it.

Parameters:

  • event The mouse press event.