Skip to content

Commit

Permalink
Use action with icon instead of push button
Browse files Browse the repository at this point in the history
Add action with an icon inside the line edit to clear the content of the line edit.
  • Loading branch information
magnesj committed Nov 2, 2023
1 parent 43c5705 commit d8b8421
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<file>Down16x16.png</file>
<file>Up16x16.png</file>
<file>duplicate.svg</file>
<file>clear.svg</file>
</qresource>
</RCC>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "cafQTreeViewStateSerializer.h"
#include "cafStyleSheetTools.h"

#include <QAction>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QPushButton>
Expand Down Expand Up @@ -74,14 +75,13 @@ PdmUiTreeView::PdmUiTreeView( QWidget* parent, Qt::WindowFlags f )
m_searchBox = new QLineEdit( this );
m_searchBox->setPlaceholderText( "Type here to search in tree." );
searchLayout->addWidget( m_searchBox );
m_clearSearchButton = new QPushButton( "X" );
m_clearSearchButton->setMaximumSize( 30, 30 );
searchLayout->addWidget( m_clearSearchButton );

QAction* clearAction = m_searchBox->addAction( QIcon( ":/caf/clear.svg" ), QLineEdit::TrailingPosition );
connect( clearAction, &QAction::triggered, this, &PdmUiTreeView::slotOnClearSearchBox );

#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
m_layout->addLayout( searchLayout );
connect( m_searchBox, SIGNAL( textChanged( QString ) ), SLOT( slotOnSearchTextChanged() ) );
connect( m_clearSearchButton, SIGNAL( clicked() ), SLOT( slotOnClearSearchBox() ) );
#endif

m_treeViewEditor = new PdmUiTreeViewEditor();
Expand Down
2 changes: 0 additions & 2 deletions Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class QItemSelection;
class QMenu;
class QModelIndex;
class QLineEdit;
class QPushButton;
class QSortFilterProxyModel;

namespace caf
Expand Down Expand Up @@ -113,7 +112,6 @@ private slots:
QString m_uiConfigName;
QVBoxLayout* m_layout;
QLineEdit* m_searchBox;
QPushButton* m_clearSearchButton;
QString m_treeStateString;
};

Expand Down

0 comments on commit d8b8421

Please sign in to comment.