Results 1 to 5 of 5

Thread: QLineEdit problem with setValidator

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy QLineEdit problem with setValidator

    Hi,

    I have this problem: When I run the program I can not write any text in QLineEdit, if I set a RegExp validator for that, although I can write if I do not set a validator. What do I do wrong?

    Details:

    I have coded exactly the same sample in the book "C++ GUI Programming with Qt4 1st ed" (Blanchette, Summerfield) in the chapter 2, "GoToCell" example.
    In that example, a new class "GoToCellDialog" is created from Ui::GoToCellDialog which inherits QDialog.
    The code in gotocelldialog.cpp is this:

    Qt Code:
    1. #include <QtGui>
    2. #include "gotocelldialog.h"
    3. GoToCellDialog::GoToCellDialog(QWidget *parent)
    4. : QDialog(parent)
    5. {
    6. setupUi(this);
    7. QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
    8. // PROBLEM HERE: lineEdit->setValidator(new QRegExpValidator(regExp, this));
    9. connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
    10. connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
    11. }
    To copy to clipboard, switch view to plain text mode 

    When I set regExp validator, I can not write any text in QLineEdit object.
    However, if I do not set the validator, I can write text.
    This problem occurs, although I have followed the example in the book.
    Why can not I use the validator?
    Any help? Any comment?

    Thank you all.
    Note: I am using Ubuntu 10.x and Qt4 sdk.
    Last edited by wysota; 20th January 2011 at 11:35. Reason: missing [code] tags

Similar Threads

  1. QLineEdit problem
    By kumarpraveen in forum Newbie
    Replies: 5
    Last Post: 12th July 2010, 12:19
  2. QLineEdit Problem
    By newermind in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2009, 14:14
  3. setValidator on QLineEdit
    By osiris81 in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2009, 14:21
  4. problem with QLineEdit and QPalette
    By impeteperry in forum Qt Programming
    Replies: 4
    Last Post: 15th October 2008, 17:05
  5. setValidator
    By :db:sStrong in forum Qt Programming
    Replies: 11
    Last Post: 16th May 2006, 09:59

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
  •  
Qt is a trademark of The Qt Company.