Вопрос

I want to use QValidator and its subclasses (QRegExpValidator, QIntValidator) in QCoreApplication, but get the following error: "QValidator: No such file or directory" If I add in .pro file the following line: "QT += gui" - all works fine, but that is not a solution for me.

Is there any technique to use QValidator in QCoreApplications?

Это было полезно?

Решение

No, this is not possible. QValidator is part of the gui lib. I suppose the Qt devs thought that QValidator makes only sense with Qt's text input classes. I checked again, above statement is still true. However, I looked into the code, QValidator does not depend on any gui stuff. On first glance it seems to be rather stand-alone. So you might be able to copy qvalidator.cpp and qvalidator.h from the Qt sources into your sources, do a reasonable amount of adjusting, and integrate this into your code. It might be possible, I don't say it will be easy.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top