Results 1 to 3 of 3

Thread: How can i have echomode in QtableView for password column?

  1. #1
    Join Date
    May 2013
    Posts
    4
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default How can i have echomode in QtableView for password column?

    In my administration window, i list a table (Qtableview) of existing users of the program. And operations for adding, editing or deleting users.

    One of the columns in the table is "Password". Currently everyone ho has access to the admin window in my program, has enough rights so i'm not hiding passwords from anyone.

    Except, there is one user called "admin" he is the pre-created user who cannot be deleted or modified by others. I want the password field to be invisible (****) for the row where the "admin" is listed. (only if the "admin" is not logged in).

    I now you have echomode for QlineEdit, that is good for in the process when inserting a new user or editing. However, i don't know how to pass the echomode with the model?

    For example, i have ordinary model wich has:

    Qt Code:
    1. QVariant UsersModel::data(const QModelIndex &index, int role) const
    2. {
    3. ...
    4. if (!index.isValid())
    5. return QVariant();
    6.  
    7. if (role == Qt::DisplayRole)
    8. {
    9. .....
    10. switch(index.column())
    11. {
    12. case 0:
    13. return object.strFirstName;
    14. case 1:
    15. return object.strLastName;
    16. case 2:
    17. return object.strLogin;
    18. case 3:
    19. return object.strPass; // how to set echomode::password (or: *****) ?
    20. }
    21. }
    To copy to clipboard, switch view to plain text mode 

    How can i have echomode in QtableView?

  2. #2
    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: How can i have echomode in QtableView for password column?

    You create a QStyledItemDelegate that you set on the column of passwords in the view (not the model, setItemDelegateForColumn()). When asked to create the editor (createEditor()) it should create a QLineEdit set to obscure the echo. You can have the delegate look at the value in another column before deciding whether to obscure the password.

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

    WinterIsComing (11th July 2013)

  4. #3
    Join Date
    May 2013
    Posts
    4
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can i have echomode in QtableView for password column?

    thanks i will look into it and respond with the results

Similar Threads

  1. How to get all column data of a QTableView
    By npascual in forum Qt Programming
    Replies: 1
    Last Post: 26th September 2012, 09:05
  2. Qtableview column get increasing
    By maarvi in forum Newbie
    Replies: 0
    Last Post: 28th June 2011, 19:21
  3. How can I lock the first column in QTableView
    By alfred4923 in forum Qt Programming
    Replies: 1
    Last Post: 10th August 2009, 08:55
  4. QLineEdit and EchoMode Passowrd
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 1st April 2009, 17:34
  5. Currently sorted column in QTableView
    By borges in forum Newbie
    Replies: 1
    Last Post: 21st September 2007, 16:52

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.