Hi guys.
I don`t remember where, but I definitely found and example on the net for validating Input on a QLineEdit.
My code is as follows:
QRegExp regexp
( "([a-zA-Z0-9]+:)*[a-zA-Z0-9]+" );
this->fileExtensionsToScan->setValidator( fileExtensionsValidator );
QRegExp regexp( "([a-zA-Z0-9]+:)*[a-zA-Z0-9]+" );
QValidator *fileExtensionsValidator = new QRegExpValidator( regexp, this );
this->fileExtensionsToScan->setValidator( fileExtensionsValidator );
To copy to clipboard, switch view to plain text mode
void MainWindow::on_fileExtensionsToScan_lostFocus(){
QString text
= this
->fileExtensionsToScan
->text
();
int pos = 0;
if ( this
->fileExtensionsToScan
->validator
()->validate
( text, pos
) != QValidator::Acceptable ) text = text.left( text.size() - 1 );
this->fileExtensionsToScan->setText( text );
}
void MainWindow::on_fileExtensionsToScan_lostFocus(){
QString text = this->fileExtensionsToScan->text();
int pos = 0;
if ( this->fileExtensionsToScan->validator()->validate( text, pos ) != QValidator::Acceptable )
text = text.left( text.size() - 1 );
this->fileExtensionsToScan->setText( text );
}
To copy to clipboard, switch view to plain text mode
Now... I`m using Fedora 7 with Qt4.3.1-3 installed with yum install qt4.
I`ve been requested to make a build of my application based on a static qt lib build so I downloaded the sources file 'qt4-4.3.1-3.fc7.src.rpm', built the static lib with
./configure -static -nomake demos -nomake examples -nomake tools -release -qt-zlib -qt-gif -qt-libpng -qt-libmng -qt-libjpeg -no-opengl -no-qdbus -no-cups
make
make install
./configure -static -nomake demos -nomake examples -nomake tools -release -qt-zlib -qt-gif -qt-libpng -qt-libmng -qt-libjpeg -no-opengl -no-qdbus -no-cups
make
make install
To copy to clipboard, switch view to plain text mode
build Makefile with qmake on my project file(same .pro file I use for the shared library version of my application, only that the qmake I used was from the static build)
then built my application.
After I did the above, I keep getting:
QMetaObject::connectSlotsByName: No matching signal for on_fileExtensionsToScan_lostFocus()
Tried switching to the connect method but still:
Object::connect: No such signal QLineEdit::lostFocus()
Object::connect: (sender name: 'fileExtensionsToScan')
Now... I see in present the documentation that no lostFocus() signal is defiend for QLineEdit but I think it was there in the recent earlier versions of 4.3.0 or 4.3.1.
Why does it work perfectly on my 4.3.1-3.fc7 build of Qt and on my static built version of Qt it does not?
Another problem I seem to have is that gif's file are not displayed although I used the above mentioned ./configure arguments.
Please enlighten me on this issue or at least provide me an alternative to the validation without subclassing.
Thank you guys.
Bookmarks