Results 1 to 5 of 5

Thread: Problems with QLineEdit

  1. #1
    Join Date
    Apr 2009
    Posts
    46
    Thanks
    4
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problems with QLineEdit

    The first problem is that QLineEdit (or maybe QLocale) does auto spaces.
    Qt Code:
    1. flags = 1048576;
    2. QLocale convert;
    3. ui->lineEditFlags->setText(convert.toString(flags));
    To copy to clipboard, switch view to plain text mode 

    And the result I get is:
    Qt Code:
    1. 1 048 576
    To copy to clipboard, switch view to plain text mode 
    ... with white spaces =/

    The second problem is that:
    Qt Code:
    1. QValidator *validator = new QIntValidator(this);
    2. ui->lineEditFlags->setValidator(validator);
    To copy to clipboard, switch view to plain text mode 

    It works fine until my program sets text to something like 1 048 576 (something that has whitespace). Then I can enter any character I want =/

    Any way to fix these?

  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: Problems with QLineEdit

    Don't use QLocale, simply
    Qt Code:
    1. ui->lineEditFlags->setText(QString::number(flags));
    To copy to clipboard, switch view to plain text mode 
    is enough.

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

    RSX (24th June 2009)

  4. #3
    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: Problems with QLineEdit

    Quote Originally Posted by RSX View Post
    The second problem is that:
    Qt Code:
    1. QValidator *validator = new QIntValidator(this);
    2. ui->lineEditFlags->setValidator(validator);
    To copy to clipboard, switch view to plain text mode 

    It works fine until my program sets text to something like 1 048 576 (something that has whitespace). Then I can enter any character I want =/
    you can also set a QLineEdit::inputMask.

  5. #4
    Join Date
    Apr 2009
    Posts
    46
    Thanks
    4
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with QLineEdit

    Thanks that worked.

  6. #5
    Join Date
    Sep 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Post Re: Problems with QLineEdit

    Hi, I have the same problem:

    I using QLineEdit and QRegExpValidator:

    1) These code is working correctly
    @lneLne1.setText("QWERTY1")
    @lneLne1.setValidator(Qt::RegExpValidator.new(Qt:: RegExp.new('[\x0410- \x044F]*'), @lneLne1)). We set invalid string "QWERTY1" in lneLne1 and set after validator for russian character. Now we can't input(manually) any character because text in @lneLne1 is invalid.

    But if we add string @lneLne1.setText("qWERTY") in the end, i.e. we have code:
    @lneLne1.setText("QWERTY1")
    @lneLne1.setValidator(Qt::RegExpValidator.new(Qt:: RegExp.new('[\x0410-\x044F]*'), @lneLne1))
    @lneLne1.setText("qWERTY")
    then validator is disabled!!!
    (I can input any symbol in field). And i can't enable it again.

    PS: I coding in RubyQt

Similar Threads

  1. Replies: 10
    Last Post: 12th February 2009, 08:23
  2. Highlidhting a single QChar in QLineEdit.
    By Zenzen in forum Qt Programming
    Replies: 2
    Last Post: 7th January 2009, 22:15
  3. QLineEdit
    By rick_st3 in forum Newbie
    Replies: 1
    Last Post: 14th June 2008, 10:05
  4. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 16:13
  5. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 02:25

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.