Results 1 to 5 of 5

Thread: QLineEdit inserting from right to left

  1. #1
    Join Date
    Feb 2013
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QLineEdit inserting from right to left

    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?

  2. #2
    Join Date
    Sep 2012
    Location
    Iran, Tehran
    Posts
    76
    Thanks
    17
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QLineEdit inserting from right to left


  3. #3
    Join Date
    May 2008
    Location
    Tripoli Libya
    Posts
    70
    Thanks
    10
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit inserting from right to left

    in main.cpp add
    Qt Code:
    1. app.setFont(QFont("tahoma")); //or any font for farsi ,arabic ,urdu,hebrew.......etc
    2. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    To copy to clipboard, switch view to plain text mode 
    for layout direction use //for each qwidget intializer
    Qt Code:
    1. this->setLayoutDirection(Qt::RightToLeft);
    To copy to clipboard, switch view to plain text mode 
    Screenshot.jpg
    Last edited by alrawab; 24th February 2013 at 18:58.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QLineEdit inserting from right to left

    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...
    Qt Code:
    1. [ 1]
    2. [ 12]
    3. [ 1.23]
    4. [ 12.35]
    5. [ 123.56]
    To copy to clipboard, switch view to plain text mode 
    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.

  5. #5
    Join Date
    Sep 2015
    Posts
    1
    Qt products
    Qt3
    Platforms
    Windows

    Red face Re: QLineEdit inserting from right to left

    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);

Similar Threads

  1. Replies: 7
    Last Post: 26th April 2012, 15:45
  2. Replies: 1
    Last Post: 12th October 2010, 23:20
  3. Replies: 4
    Last Post: 29th August 2010, 19:16
  4. Inserting Record
    By Nefastious in forum Newbie
    Replies: 3
    Last Post: 20th October 2009, 05:28
  5. Inserting PDF metadata
    By Randria in forum Qt Programming
    Replies: 2
    Last Post: 18th May 2009, 11:18

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.