[Interest] QLIneEdit Bug still valid ?

R. Reucher rene.reucher at batcom-it.net
Mon Jul 16 13:38:58 CEST 2012


On Monday 16 July 2012 09:14:31 Constantin Makshin wrote:
> Functions you are interested in are (line numbers are taken from the code
> in the Git repository):
> src/gui/widgets/qlineedit.cpp, line 383 (QLineEdit::setText)
> src/gui/widgets/qlinecontrol_p.h, line 213 (QLineControl::setText)
> src/gui/widgets/qlinecontrol.cpp, line 676 (QLineControl::internalSetText)
> src/gui/widgets/qlinecontrol.cpp, line 620 (QLineControl::finishChange)
> 
> Nothing looks wrong there...
Yeah, I also recall it was working correctly when I used it last time...

However, the example acts "wrongly", but it somehow only happens when the 
validator is set. The attached example (w/o the validator) works correctly.

HTH, René
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120716/f0f9559f/attachment.html>
-------------- next part --------------
#include <QtGui>

class QUppercaseValidator : public QValidator
{
        public:
                QUppercaseValidator(QObject *parent) : QValidator(parent) {}
                virtual State validate(QString &s, int &) const { fixup(s); return Acceptable; }
                virtual void fixup(QString &s) const { s = s.toUpper(); }
};

int main(int argc, char *argv[])
{
        QApplication a(argc, argv);

        QWidget w;
        QLineEdit *edit1 = new QLineEdit;
        QLineEdit *edit2 = new QLineEdit;
        QLabel *label = new QLabel;
        //edit2->setValidator(new QUppercaseValidator(edit2));
        QObject::connect(edit1, SIGNAL(textChanged(const QString &)), edit2, SLOT(setText(const QString &)));
        QObject::connect(edit2, SIGNAL(textEdited(const QString &)), label, SLOT(setText(const QString &)));
        QVBoxLayout *layout = new QVBoxLayout;
        layout->addWidget(edit1);
        layout->addWidget(edit2);
        layout->addWidget(label);
        w.setLayout(layout);
        w.show();

        return a.exec();
}


More information about the Interest mailing list