Results 1 to 4 of 4

Thread: QLineEdit and setInputMask

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    9
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question QLineEdit and setInputMask

    Hi,

    When I run my program the default text displayed in the field is a zero with 6 spaces behind it instead of "0" (a zero without spaces behind it).(I didn't encounter any errors of any kind)

    What do I need to do to get rid of those spaces?
    Qt Code:
    1. QLineEdit *qleobject = new QLineEdit(this);
    2. qleobject->setInputMask("0000000");
    3. qleobject->setText("0");
    4. qleobject->setAlignment(Qt::AlignRight);
    To copy to clipboard, switch view to plain text mode 


    Uploaded with ImageShack.us
    Last edited by mr_kazoodle; 22nd January 2011 at 20:05.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit and setInputMask

    I would consider using QIntValidator instead.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    mr_kazoodle (22nd January 2011)

  4. #3
    Join Date
    Jan 2011
    Posts
    9
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QLineEdit and setInputMask

    Thank you very much for helping me.
    This is the result:
    Qt Code:
    1. QLineEdit *qleobject = new QLineEdit(this);
    2. qleobject->setText("0");
    3. qleobject->setAlignment(Qt::AlignRight);
    4.  
    5. QIntValidator *val = new QIntValidator(0,2147483647,this);
    6. qleobject->setValidator(val);
    7.  
    8. qApp->connect(//more code...
    To copy to clipboard, switch view to plain text mode 
    Edit: Where do I mark the thread as solved, I can't seem to find it? (I'm sorry for the trouble)

  5. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit and setInputMask

    Edit: Where do I mark the thread as solved, I can't seem to find it?
    No real need to, the thread just ends, and who ever reads it can see it was resolved or not.
    But you can edit the title if you like (some people do).
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 1
    Last Post: 12th October 2010, 22:20
  2. help with QLineEdit
    By benlyboy in forum Newbie
    Replies: 2
    Last Post: 18th February 2010, 01:39
  3. QLineEdit
    By bismitapadhy in forum Qt Programming
    Replies: 3
    Last Post: 11th August 2009, 08:24
  4. Tab QLineEdit
    By jaca in forum Qt Programming
    Replies: 1
    Last Post: 13th May 2008, 13:01
  5. QLineEdit
    By coderbob in forum Qt Programming
    Replies: 6
    Last Post: 27th February 2008, 12:27

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
  •  
Qt is a trademark of The Qt Company.