Skip to content
Permalink
Browse files

Add the hint as a placeholder on text edit

  • Loading branch information
pblottiere committed Jul 6, 2017
1 parent e5eda5f commit df5551a2b73284444c9728c36019458064004361
Showing with 21 additions and 0 deletions.
  1. +13 −0 src/gui/editorwidgets/qgstexteditwrapper.cpp
  2. +8 −0 src/gui/editorwidgets/qgstexteditwrapper.h
@@ -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 );
}
@@ -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;
@@ -66,6 +73,7 @@ class GUI_EXPORT QgsTextEditWrapper : public QgsEditorWidgetWrapper
QPalette mReadOnlyPalette;
QPalette mWritablePalette;
QString mPlaceholderText;
QString mPlaceholderTextBackup;

void setWidgetValue( const QVariant &value );
};

0 comments on commit df5551a

Please sign in to comment.
You can’t perform that action at this time.