Results 1 to 12 of 12

Thread: QLineedit mask

  1. #1
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default QLineedit mask

    Hi All
    I've a lineedit control . i need to use it as a IP input field. i ve given the like below.

    setInputMask("000.000.000.000; X");

    But instead of X i need to show blank space only, till i give input to this field. and all 3 dots should ve same gap.. how to do it? Plz help
    thanx.

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QLineedit mask

    Try this; setInputMask("000.000.000.000 X;");

  3. #3
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QLineedit mask

    Quote Originally Posted by zgulser View Post
    Try this; setInputMask("000.000.000.000 X;");
    Ya its working. but i need the gap between should be same. like

    | . . . . | ----------> assume that this is my QLineedit. so the space is equally divided.

  4. #4
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QLineedit mask

    Can you show/display what you want with numbers? Please visualize it.

  5. #5
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QLineedit mask

    Quote Originally Posted by zgulser View Post
    Can you show/display what you want with numbers? Please visualize it.
    I want a linedit for entering IP address. and the gap betewwn all . should be equal, as in attachment. and it sholud display blank filed. Please chech the attached ui.
    Attached Files Attached Files

  6. #6
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QLineedit mask

    Hey, please don't misunderstand me but I couldn't get the point of what you trying to do...Don't send me another .ui file. Just type simply..

    But as far as I understand you're trying the following

    0000 . 0000 . 0000 . 0000 ( if not please just type what you want with numbers)

  7. #7
    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 mask

    I think that the OP wants a text box into which an IP address can be typed. Before anything is entered the OP wants the text box to look like:
    Qt Code:
    1. +---------------+
    2. | . . . |
    3. +---------------+
    To copy to clipboard, switch view to plain text mode 
    and have the digits fill in around the dots as the user types:
    Qt Code:
    1. +---------------+
    2. |192. 0. 2. 34|
    3. +---------------+
    To copy to clipboard, switch view to plain text mode 
    Setting the input mask to "000.000.000.000" (perhaps "009.009.009.009" or "900.900.900.900") should give the space fillers, i.e. space is the default if there is none specified. You would also need a validator to check the range of the digits entered.

    The OP also seems to require that, when empty, the dots should be evenly spaced. The dots will move about as typing continues unless a monospaced font is used for the line edit. Set the width of the line edit based on the calculated width of the mask in that font and all should be good.

  8. #8
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QLineedit mask

    Quote Originally Posted by sudhansu View Post
    I want a linedit for entering IP address. and the gap betewwn all . should be equal, as in attachment. and it sholud display blank filed.
    You have to set a fixed size to your line edit. To calculate that use QFontInfo.

  9. #9
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QLineedit mask

    You mean variable size for IP address fields Chris?

  10. #10
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QLineedit mask

    Quote Originally Posted by Lykurg View Post
    You have to set a fixed size to your line edit. To calculate that use QFontInfo.
    lineedit size is fixed to 121*26. and font is A[Sans, 10]. how to calculate the size using QFontInfo?

  11. #11
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QLineedit mask

    ups, I wanted to say QFontMetrics. See QFontMetrics::width() with "999.999.999.999".

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QLineedit mask

    Set a monospaced font on the line edit.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QLineEdit and input mask
    By tpf80 in forum Qt Programming
    Replies: 7
    Last Post: 9th May 2014, 19:47
  2. Replies: 5
    Last Post: 10th July 2009, 12:11
  3. Mixing QRegExpValidator and input mask and QLineEdit
    By abernat in forum Qt Programming
    Replies: 1
    Last Post: 18th February 2009, 00:04
  4. Qt 4 expanded mask
    By bunjee in forum Qt Programming
    Replies: 4
    Last Post: 7th May 2008, 14:21
  5. help with.. numeric mask....
    By ocascante in forum Qt Tools
    Replies: 1
    Last Post: 12th July 2007, 09:53

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.