+/**
+* Customization of Line edit control
+*/
+class CustomLineEdit : public QLineEdit
+{
+public:
+ /// Constructor
+ /// \param theParent a parent widget
+ /// \param thePlaceHolder a string which is shown when text is empty
+ CustomLineEdit( QWidget* theParent, const QString& thePlaceHolder )
+ : QLineEdit( theParent ), myPlaceHolder( thePlaceHolder )
+ {
+ }
+
+ virtual ~CustomLineEdit()
+ {
+ }
+
+ /// Redefiniotion of virtual method
+ /// \param theEvent a paint event
+ virtual void paintEvent( QPaintEvent* theEvent )
+ {
+ QLineEdit::paintEvent( theEvent );
+ if( text().isEmpty() && !myPlaceHolder.isEmpty() )
+ {
+ QPainter aPainter( this );
+ QRect aRect = rect();
+ int aHorMargin = 5;
+ aRect.adjust( aHorMargin, 0, 0, 0 );
+
+ QColor aColor = palette().text().color();
+ aColor.setAlpha( 128 );
+ QPen anOldpen = aPainter.pen();
+ aPainter.setPen( aColor );
+ QFontMetrics aFontMetrics = fontMetrics();
+ QString elidedText = aFontMetrics.elidedText( myPlaceHolder, Qt::ElideRight, aRect.width() );
+ aPainter.drawText( aRect, Qt::AlignLeft | Qt::AlignVCenter, elidedText );
+ aPainter.setPen( anOldpen );
+ }
+ }
+
+private:
+ QString myPlaceHolder;
+};
+