Results 1 to 5 of 5

Thread: Masking password in QTreeView

  1. #1
    Join Date
    Sep 2011
    Posts
    45
    Thanks
    17
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Question Masking password in QTreeView

    Hello!

    I need to display bullets instead of actual password's signs in QTreeView's item. For this purpose I created own delegate: QLineEdit with echo mode 'Password'. Yes, for input it works perfectly. But here is a pitfall: setModelData -method. It will always display an actual data. My question is: Is any smart way to mask the password in QTreeView? Is it possible?

    Thank you for your answers beforehand.

  2. #2
    Join Date
    Sep 2011
    Posts
    45
    Thanks
    17
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Post Re: Masking password in QTreeView

    OK, I thought about that. And here is result: actual password will be copied into internal variable and instead of letters shall be put bullets "•"(alt + 0149).
    For instance: "Hello!" - "••••••". So, it's just a decoration for an user.
    I didn't see any smart ways to do that.

  3. #3
    Join Date
    Sep 2011
    Posts
    45
    Thanks
    17
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Masking password in QTreeView

    Here is another problem... Instead of bullets, QTreeView shows question-marks.
    Here is the code:
    Qt Code:
    1. item.setText(QString::fromUtf8("\x0095"));
    To copy to clipboard, switch view to plain text mode 

    Guys, do you have any ideas, how it can be fixed?

  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: Masking password in QTreeView

    The character you are trying to get is 149 in the Windows CP 1252 code page. Its equivalent Unicode code point is U+2022 BULLET (http://www.unicode.org/charts/PDF/U2000.pdf). The UTF-8 encoding of U+2022 is three bytes E2 80 A2 (in hex, see http://people.w3.org/rishida/tools/conversion/ for useful tool).
    So, you could use any of these:
    Qt Code:
    1. QChar bullet(0x2022);
    2. QString bullet = QString::fromStdWString(L"\x2022");
    3. QString bullet = QString::fromUtf8("\xe2\x80\xa2");
    To copy to clipboard, switch view to plain text mode 
    depending on whether you want a single char or a string

  5. The following user says thank you to ChrisW67 for this useful post:

    DmitryNik (24th October 2011)

  6. #5
    Join Date
    Sep 2011
    Posts
    45
    Thanks
    17
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Masking password in QTreeView

    Thank you! It works.

Similar Threads

  1. Dynamic masking...?
    By lar0che in forum Newbie
    Replies: 1
    Last Post: 16th August 2010, 07:23
  2. Delayed Password Masking
    By branko in forum Qt Programming
    Replies: 5
    Last Post: 23rd March 2010, 09:32
  3. Intense Masking....
    By been_1990 in forum Qt Programming
    Replies: 20
    Last Post: 30th April 2009, 16:03
  4. Issue with masking QWidgets
    By JimDaniel in forum Qt Programming
    Replies: 6
    Last Post: 2nd November 2007, 19:23
  5. Masking password
    By Lebowski in forum Qt Tools
    Replies: 3
    Last Post: 14th April 2006, 11:17

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.