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:
#include <QtGui>
#include "gotocelldialog.h"
GoToCellDialog
::GoToCellDialog(QWidget *parent
){
setupUi(this);
QRegExp regExp
("[A-Za-z][1-9][0-9]{0,2}");
// PROBLEM HERE: lineEdit->setValidator(new QRegExpValidator(regExp, this));
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
#include <QtGui>
#include "gotocelldialog.h"
GoToCellDialog::GoToCellDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
// PROBLEM HERE: lineEdit->setValidator(new QRegExpValidator(regExp, this));
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
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.
Bookmarks