Results 1 to 11 of 11

Thread: How could I make the QLineEdit UpperCase without using InputMask?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2007
    Location
    Ankara TURKEY
    Posts
    32
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face How could I make the QLineEdit UpperCase without using InputMask?

    How could I make the QLineEdit UpperCase without using InputMask.
    I don't want to use it because when I use it inputMask like ">AAAAAAA" the curser doesn't starts begenning of the line. It start where ever I click in the line.

    I need to delegate the lines by using "promote to" with QtDesigner.

    Can you please write an example delegate class for QLineEdit

    I did it for line in a QTableWidget but not an indepandent QLineEdit
    It is Like:

    Qt Code:
    1. QWidget *AlternatifDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
    2. {
    3. QLocale::setDefault(QLocale(QLocale::Turkish, QLocale::Turkey));
    4. QLineEdit *editor = new QLineEdit(parent);
    5. QFont font;
    6. font.setCapitalization(QFont::AllUppercase);
    7. editor->setFont(font);
    8. return editor;
    9. }
    10. void AlternatifDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
    11. {
    12. QLocale turkish(QLocale::Turkish);
    13. QString value = index.model()->data(index, Qt::DisplayRole).toString();
    14. QLineEdit *qline = static_cast<QLineEdit*>(editor);
    15. QFont font;
    16. font.setCapitalization(QFont::AllUppercase);
    17. editor->setFont(font);
    18. qline->setText(value);
    19. }
    20. void AlternatifDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
    21. const QModelIndex &index) const
    22. {
    23. QLocale turkish(QLocale::Turkish);
    24. QLineEdit *qline = static_cast<QLineEdit*>(editor);
    25. QFont font;
    26. font.setCapitalization(QFont::AllUppercase);
    27. editor->setFont(font);
    28. QString value = qline->text();
    29. model->setData(index, value.toUpper());
    30. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by uygar; 11th February 2009 at 10:55.

Similar Threads

  1. how to make system calls to be displayed in QLineEdit
    By wagmare in forum Qt Programming
    Replies: 2
    Last Post: 10th November 2008, 06:08
  2. how to make the QLineEdit uneditable by user
    By wagmare in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2008, 10:20
  3. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 16:13
  4. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 02:25
  5. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 06:57

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.