PDA

View Full Version : QLineEdit inserting from right to left



allyxcristiano
23rd February 2013, 13:14
I would like the text to be inserted from right to left style commercial bank, I'm using a mask with a "," type #####,##
Have you researched how to make and found no solution, anyone have any idea how to solve this?

Ashkan_s
23rd February 2013, 14:35
Found this http://stackoverflow.com/questions/10998105/qt-how-to-change-the-direction-of-placeholder-in-a-qlineedit it may be useful

alrawab
24th February 2013, 17:53
in main.cpp add


app.setFont(QFont("tahoma")); //or any font for farsi ,arabic ,urdu,hebrew.......etc
QTextCodec::setCodecForCStrings(QTextCodec::codecF orName("UTF-8"));

for layout direction use //for each qwidget intializer


this->setLayoutDirection(Qt::RightToLeft);

8768

ChrisW67
25th February 2013, 04:08
I think the OP wants the numeric entry to fill from the right with a forced decimal point like a commercial calculator, not text in a RTL language. For example, entering 123.56 one digit at a time...


[ 1]
[ 12]
[ 1.23]
[ 12.35]
[ 123.56]

Simple right-alignment gets part way there, but the input mask causes issues. There should be a way to use the alignment with a QValidator instead of the mask. Have QValidator::validate() remove any non-digit, insert a decimal two chars from the right (if the string is long enough), and set the editor's string.

Toufikbodo
21st September 2015, 11:05
If it was intended as said colleague ChrisW67

Thus the solution
QLineEdit=new QLineEdit(this);
QDoubleValidator *myDblVal = new QDoubleValidator(0, 99999999999999, 2,LineEdit );
LineEdit->setValidator(myDblVal);
LineEdit->setAlignment(Qt::AlignRight);