当前位置:网站首页>Qdoublevalidator does not take effect solution
Qdoublevalidator does not take effect solution
2022-07-27 09:00:00 【Cotoneaster in the grass】
problem :
Use QIntValidator normal , Replace with QDoubleValidator It will not take effect after , Look at what is said on the Internet to increase this line :setNotation(QDoubleValidator::StandardNotation);
It doesn't seem to work , I had to write one myself , At present, the test feels OK .
terms of settlement :
heavy load QDoubleValidator.
class MyDoublevalidator : public QDoubleValidator
{
Q_OBJECT
public:
MyDoublevalidator(QObject *parent = nullptr);
QValidator::State validate(QString &str, int &i) const;
};
MyDoublevalidator::MyDoublevalidator(QObject *parent)
{
}
QValidator::State MyDoublevalidator::validate(QString &str,int &i) const
{
qDebug() << "validate in: str" << str;
if(str == "-" || str == ""){
return Intermediate;
}
bool ok;
double number = str.toDouble(&ok);
if(!ok){
return Invalid;
}
// Judge the decimal point
int dotPos = str.indexOf('.');
if( (dotPos != -1) && (str.length()-dotPos - 1 > decimals()) ){
return Invalid;
}
// Distinguish between negative and positive numbers
if(number >= 0)
{
if(number < bottom()){
return Intermediate;
}
if(number > top()){
return Invalid;
}
}
else
{
// negative
if(number < bottom()){
return Invalid;
}
if(number > top()){
return Intermediate;
}
}
return Acceptable;
}
边栏推荐
- Matlab solves differential algebraic equations (DAE)
- 接口测试工具-Postman使用详解
- Can "Gulangyu yuancosmos" become an "upgraded sample" of China's cultural tourism industry
- flex布局 (实战小米官网)
- 3428. 放苹果
- Test picture
- Storage and computing engine
- Pyqt5 rapid development and practice 4.1 qmainwindow
- String type and bitmap of redis
- 2036: [Blue Bridge Cup 2022 preliminary] statistical submatrix (two-dimensional prefix sum, one-dimensional prefix sum)
猜你喜欢

Understand various IOU loss functions in target detection

CUDA Programming -03: thread level

NIO示例

Five kinds of 3D attention/transformer finishing (a-scn, point attention, CAA, offset attention, point transformer)

网络IO总结文

Mmrotate trains its dataset from scratch

Pyqt5 rapid development and practice 4.1 qmainwindow

Include error in vs Code (new header file)

8 kinds of visual transformer finishing (Part 1)

ctfshow 终极考核
随机推荐
Matlab数据导入--importdata和load函数
Explain cache consistency and memory barrier
Matlab drawing skills and examples: stackedplot
500报错
Hangzhou E-Commerce Research Institute released an explanation of the new term "digital existence"
CUDA programming-04: CUDA memory model
4279. Cartesian tree
3428. Put apples
Digital intelligence innovation
QDoubleValidator不生效问题解决办法
PyQt5快速开发与实战 4.1 QMainWindow
tensorflow包tf.keras模块构建和训练深度学习模型
CUDA programming-05: flows and events
Tensorflow loss function
Rewrite the tensorrt version deployment code of yolox
Network IO summary
NIO this.selector.select()
Redis network IO
存储和计算引擎
4275. Dijkstra sequence