Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Qt - QRegExp preventing text entry in QLineEdit

Posted on 2010-09-11
1
Medium Priority
?
1,268 Views
Last Modified: 2013-11-23
I am a beginner with Qt.  I am working through examples in the C++ GUI Programming with Qt4 book.  In the Chapter 2 GoToCellDialog example I have used Designer to create a small dialog with a QLineEdit (lineEdit) and am adding a regular expression for validation.  Here is the dialog's source code:

#include "gotocelldialog.h"
#include "ui_gotocelldialog.h"

GoToCellDialog::GoToCellDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::GoToCellDialog)
{
    ui->setupUi(this);

    QRegExp regExp("[A-Za-z][1-9][0-9]{0-2}");
    ui->lineEdit->setValidator(new QRegExpValidator (regExp, this));

    connect (ui->okButton, SIGNAL(clicked()), this, SLOT(accept()));
    connect (ui->cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}

void GoToCellDialog::on_lineEdit_textChanged()
{
    ui->okButton->setEnabled(ui->lineEdit->hasAcceptableInput());
}
//  Destructor omitted

When running this in Debug mode I am unable to enter any text in the QLineEdit window.  If I comment out the setValidator call, I am then able to enter text in the window.  I am using QtCreator 2.0.0 which says it is based on Qt 4.7.0.  Thanks for your help.

David
0
Comment
Question by:dcoggin1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
dcoggin1 earned 0 total points
ID: 33653488
My error was in the QRegExp.  I had a dash where I should have had a comma -- {0-2} should have been {0,2}.  I don't think {0-2} is a legal syntax, so I'm surprised it compiled.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question