mirror of
https://gitee.com/drabel/LibQQt.git
synced 2025-01-04 10:18:44 +08:00
update lineeditwithsearch
This commit is contained in:
parent
d1f8b28c30
commit
6499def2e0
@ -1,40 +1,45 @@
|
||||
#include "qqtlineeditwithsearch.h"
|
||||
#include "qqtlineeditwithsearch.h"
|
||||
#include <QHBoxLayout>
|
||||
#include "qqtwidgets.h"
|
||||
|
||||
QQtLineEditWithSearch::QQtLineEditWithSearch(QWidget* parent) :
|
||||
QLineEdit(parent)
|
||||
QQtLineEditWithSearch::QQtLineEditWithSearch ( QWidget* parent ) :
|
||||
QLineEdit ( parent )
|
||||
{
|
||||
m_btnBrower = new QPushButton(this);
|
||||
QSize size = QSize(sizeHint().height(), sizeHint().height());
|
||||
m_btnBrower->setFixedSize(size);
|
||||
m_btnBrower->setFocusPolicy(Qt::NoFocus); // 得到焦点时,不显示虚线框
|
||||
m_btnBrower->setFlat(true);
|
||||
m_btnBrower->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
m_btnBrower->setIcon(QIcon("./skin/default/bt_brower.png"));
|
||||
m_btnBrower->setIconSize(size);
|
||||
m_btnBrower = new QPushButton ( this );
|
||||
QSize size = QSize ( sizeHint().height(), sizeHint().height() );
|
||||
m_btnBrower->setFixedSize ( size );
|
||||
m_btnBrower->setFocusPolicy ( Qt::NoFocus ); // 得到焦点时,不显示虚线框
|
||||
m_btnBrower->setFlat ( true );
|
||||
m_btnBrower->setCursor ( QCursor ( Qt::PointingHandCursor ) );
|
||||
m_btnBrower->setIcon ( QIcon ( "./skin/default/bt_brower.png" ) );
|
||||
m_btnBrower->setIconSize ( size );
|
||||
|
||||
QHBoxLayout* hLayout = new QHBoxLayout(this);
|
||||
hLayout->setContentsMargins(0, 0, 1, 0);
|
||||
QHBoxLayout* hLayout = new QHBoxLayout ( this );
|
||||
hLayout->setContentsMargins ( 0, 0, 1, 0 );
|
||||
hLayout->addStretch();
|
||||
hLayout->addWidget(m_btnBrower);
|
||||
setLayout(hLayout);
|
||||
hLayout->addWidget ( m_btnBrower );
|
||||
setLayout ( hLayout );
|
||||
|
||||
/*
|
||||
* 设置输入框中文件输入区,不让输入的文字在被隐藏在按钮下
|
||||
*/
|
||||
setTextMargins(0, 1, size.width(), 1);
|
||||
setTextMargins ( 0, 1, size.width(), 1 );
|
||||
|
||||
connect(m_btnBrower, SIGNAL(clicked()), this, SIGNAL(btnClicked()));
|
||||
connect ( m_btnBrower, SIGNAL ( clicked() ), this, SIGNAL ( btnClicked() ) );
|
||||
}
|
||||
|
||||
void QQtLineEditWithSearch::setButtonText(QString text)
|
||||
void QQtLineEditWithSearch::setButtonText ( QString text )
|
||||
{
|
||||
m_btnBrower->setText(text);
|
||||
m_btnBrower->setText ( text );
|
||||
}
|
||||
|
||||
void QQtLineEditWithSearch::setObjectName(const QString& name)
|
||||
void QQtLineEditWithSearch::setButtonIcon ( QString icon )
|
||||
{
|
||||
QLineEdit::setObjectName(name);
|
||||
m_btnBrower->setObjectName(QString("%1_button").arg(name));
|
||||
m_btnBrower->setIcon ( QIcon ( icon ) );
|
||||
}
|
||||
|
||||
void QQtLineEditWithSearch::setObjectName ( const QString& name )
|
||||
{
|
||||
QLineEdit::setObjectName ( name );
|
||||
m_btnBrower->setObjectName ( QString ( "%1_button" ).arg ( name ) );
|
||||
}
|
||||
|
@ -14,7 +14,9 @@ class QQTSHARED_EXPORT QQtLineEditWithSearch : public QLineEdit
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtLineEditWithSearch ( QWidget* parent = 0 );
|
||||
|
||||
void setButtonText ( QString text );
|
||||
void setButtonIcon ( QString image );
|
||||
void setObjectName ( const QString& name );
|
||||
|
||||
signals:
|
||||
|
Loading…
x
Reference in New Issue
Block a user