将spinbox重写虚函数,支持16进制微调框
来源:互联网 发布:国家网络安全法文件 编辑:程序博客网 时间:2024/06/08 09:29
//head
#ifndef HEXSPINBOX_H
#define HEXSPINBOX_H
#include <QSpinBox>
class QRegExpValidator;
class HexSpinBox : public QSpinBox
{
Q_OBJECT
public:
HexSpinBox(QWidget *parent = 0);
protected:
QValidator::State validate(QString &text, int &pos) const;
int valueFromText(const QString &text) const;
QString textFromValue(int value) const;
private:
QRegExpValidator *validator;
};
#endif
//cpp
#include <QtGui>
#include "hexspinbox.h"
HexSpinBox::HexSpinBox(QWidget *parent)
: QSpinBox(parent)
{
setRange(0, 255);
validator = new QRegExpValidator(QRegExp("[0-9A-Fa-f]{1,8}"), this);
}
QValidator::State HexSpinBox::validate(QString &text, int &pos) const
{
return validator->validate(text, pos);
}
int HexSpinBox::valueFromText(const QString &text) const
{
bool ok;
return text.toInt(&ok, 16);
}
QString HexSpinBox::textFromValue(int value) const
{
return QString::number(value, 16).toUpper();
}
偶尔翻着看看
0 0
- 将spinbox重写虚函数,支持16进制微调框
- spinbox
- QSpinBox子类化一例(进制可变的SpinBox)
- QSpinBox子类化一例(进制可变的SpinBox)
- 微调
- 称将微调信贷退税等政策
- Spinbox 实例
- spinbox.html
- 函数重写
- .ISAPI_Rewrite 支持二级域名重写
- 微调︱caffe中fine-tuning模型三重天(函数详解、框架简述)+微调技巧
- 虚函数,纯虚函数。函数重写,函数隐藏。
- QT中spinbox的使用&获取系统时间&写槽函数
- 重写虚函数的一些感悟
- c# 虚函数Virtual与重写override
- 理解C++重载、重写、虚函数
- 将16进制字符串转换为整数的函数
- keras 迁移学习, 微调, model的predict函数定义
- C#中dynamic的正确用法
- 链式堆栈
- MATLAB 声卡连续信号采集
- neHe OpenGL lession 5
- CentOS6.5安装MRBS
- 将spinbox重写虚函数,支持16进制微调框
- iOS实现打电话功能
- [leetcode] Search in Rotated Sorted Array II
- C++11新标准之三:nullptr
- 1229 数字游戏
- java基本数据类型初始值(默认值) ,在设计数据库时造成的问题
- sqlserver2008添加删除字段
- unix信号转载
- 译文:前端性能的重要性 The Importance of Frontend Performance