Results 1 to 6 of 6

Thread: Font and lineedit

  1. #1
    Join Date
    Sep 2009
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Font and lineedit

    Hi ,

    Is there any font which QlineEdit supports to display the non-Printable characters .

  2. #2
    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: Font and lineedit

    You can use any font installed at your operating system with QLineEdit you just have to set it with setFont(). Further you can use a non installed font by register it to the QApplication instance.

  3. #3
    Join Date
    Sep 2009
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Font and lineedit

    Actually the problem is that when i want to display a non-printable character its not being displayed in lineedit.Any idea what should i do to display it

  4. #4
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Font and lineedit

    Well what does printing non-printable characters mean? Like how do you print BACKSPACE, EOT, ETX, STX, etc..
    AFAIK thats not possible in Qt.

    What is your use case? May be that may help to find a way out.

  5. #5
    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: Font and lineedit

    Quote Originally Posted by Raghaw View Post
    Actually the problem is that when i want to display a non-printable character its not being displayed in lineedit.Any idea what should i do to display it
    They are called non-printable for a reason. They have no glyph in the vast majority of fonts, and they have special meanings that may be used e.g. the bell or escape character. If you want non-printables to be displayed as some substitute character then substitute that character before display:
    Qt Code:
    1. QString test = QString::fromUtf8(
    2. "this string \v contains \ba\x01\x02 few odd characters\004"
    3. "including a non-character \xEF\xB7\x90"
    4. "and one defined as having no visible appearance >>\xE2\x80\x8C<<"
    5. );
    6.  
    7. qDebug() << test;
    8. for (int i = 0; i < test.size(); ++i)
    9. if (!test.at(i).isPrint())
    10. test[i] = QChar(QChar::ReplacementCharacter); // Unicode defines this character
    11. qDebug () << test;
    To copy to clipboard, switch view to plain text mode 
    Last edited by ChrisW67; 17th May 2012 at 09:02.

  6. #6
    Join Date
    Sep 2009
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Font and lineedit

    Thanks for replying...

    Mine problem is that i have one lineedit which can be used to display hexadecimal and ANSI format of strings..I using a input mask in case of hexadecimal formatSo there is one comobox of Hexadecimal and ANSI option.if u choose Hexadecimal input mask will appear and is u choose ANSI option the Mask will dissapear and the corresponding values written in hexadecimal will be displayed in ANSI format and vice-verse.

    Suppose u enter in HEX 0x23 it will display # in ANSI mode and vice versa.

    Now here comes the problem ::
    If u enter a value less than 0x20 it will a non printable character and hence a space will be created in place of that.So this will be confusion for user as he wont be to figurea space.So what i did i used a Text edit in place Lieneedit when u select a ANSI mode so that a square is generated when ever a non printable character is written.

    But this creates many problem suppose if put "0x0D" in HEX and switch to ANSI and again switch to HEX it displays "0x0A" instead of 0x0D.

    Is there any way i can show square in place of non printable character in lineedit also.

    Please reply back.


    Added after 5 minutes:


    Thanks ChrisW67 .Is there any way also i can extract the characters which were replaced by replacement character.
    Last edited by Raghaw; 21st May 2012 at 11:44.

Similar Threads

  1. Replies: 1
    Last Post: 30th March 2012, 16:46
  2. Font Height and width based on font size
    By Ghufran in forum Qt Programming
    Replies: 1
    Last Post: 31st July 2010, 08:02
  3. Change Font of QListWidget to Monospace Font
    By pospiech in forum Qt Programming
    Replies: 3
    Last Post: 25th July 2008, 18:23
  4. font incorrectly show - font break.
    By sgh in forum Qt Programming
    Replies: 9
    Last Post: 30th May 2008, 02:35
  5. Replies: 1
    Last Post: 25th December 2007, 10:35

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.