本文整理汇总了C++中QRegExpValidator::setLocale方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegExpValidator::setLocale方法的具体用法?C++ QRegExpValidator::setLocale怎么用?C++ QRegExpValidator::setLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegExpValidator
的用法示例。
在下文中一共展示了QRegExpValidator::setLocale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
EEPROMWindow::EEPROMWindow(QStringList eepromLines, QWidget *parent) :
QDialog(parent),
ui(new Ui::EEPROMWindow)
{
ui->setupUi(this);
QSettings settings;
firmware = settings.value("printer/firmware").toInt();
QLayout *layout = new QVBoxLayout();
if(firmware == Repetier)
{
int j = 0;
foreach (QString str, eepromLines)
{
str.remove("EPR:"); // Clear the unneeded part
repetierEEPROMline currentLine; //Storage for EEPROM values
QStringList tmp = str.split(' ');
currentLine.T = tmp.at(0).toInt();
currentLine.P = tmp.at(1).toInt();
currentLine.S = tmp.at(2);
lines.append(currentLine);
QString msg;
for(int i = 3; i < tmp.size(); i++) msg+=(tmp.at(i) + " "); //Rejoin the rest
QLayout *line = new QGridLayout();
QLabel *label = new QLabel(msg, this);
QLineEdit *edit = new QLineEdit(currentLine.S,this);
QFrame* hline = new QFrame();
hline->setFrameShape(QFrame::HLine);
hline->setFrameShadow(QFrame::Sunken);
line->addWidget(hline);
edit->setObjectName("e"+QString::number(j)); //Name the LineEdit, so when it emits signal we know where it came from
QRegExpValidator *doublevalidator = new QRegExpValidator(
QRegExp("^\\-?\\d+\\.?\\d+(e\\-?\\d+)?$",
Qt::CaseInsensitive), this);
doublevalidator->setLocale(QLocale::English);
switch(currentLine.T) // set right validator for the line
{
case 0:
edit->setValidator(new QIntValidator(-128, 255, this));
case 1:
case 2:
edit->setValidator(new QIntValidator(this));
break;
case 3:
edit->setValidator(doublevalidator);
break;
default:
break;
}
connect(edit, &QLineEdit::textChanged, this, &EEPROMWindow::lineChanged);
line->addWidget(label);
line->addWidget(edit);
line->setMargin(2);
layout->addItem(line);
j++; // increase counter
}