Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add the hint as a placeholder on text edit
  • Loading branch information
pblottiere committed Jul 6, 2017
1 parent e5eda5f commit df5551a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/gui/editorwidgets/qgstexteditwrapper.cpp
Expand Up @@ -240,3 +240,16 @@ void QgsTextEditWrapper::setWidgetValue( const QVariant &val )
if ( mLineEdit )
mLineEdit->setText( v );
}

void QgsTextEditWrapper::setHint( const QString &hintText )
{
if ( hintText.isNull() )
mPlaceholderText = mPlaceholderTextBackup;
else
{
mPlaceholderTextBackup = mPlaceholderText;
mPlaceholderText = hintText;
}

mLineEdit->setPlaceholderText( mPlaceholderText );
}
8 changes: 8 additions & 0 deletions src/gui/editorwidgets/qgstexteditwrapper.h
Expand Up @@ -47,6 +47,13 @@ class GUI_EXPORT QgsTextEditWrapper : public QgsEditorWidgetWrapper
QVariant value() const override;
void showIndeterminateState() override;

/**
* Add a hint text on the widget
* \param hintText The hint text to display
* \since QGIS 3.0
*/
void setHint( const QString &hintText ) override;

protected:
QWidget *createWidget( QWidget *parent ) override;
void initWidget( QWidget *editor ) override;
Expand All @@ -66,6 +73,7 @@ class GUI_EXPORT QgsTextEditWrapper : public QgsEditorWidgetWrapper
QPalette mReadOnlyPalette;
QPalette mWritablePalette;
QString mPlaceholderText;
QString mPlaceholderTextBackup;

void setWidgetValue( const QVariant &value );
};
Expand Down

0 comments on commit df5551a

Please sign in to comment.