本文整理汇总了C++中WLineEdit::setValidator方法的典型用法代码示例。如果您正苦于以下问题:C++ WLineEdit::setValidator方法的具体用法?C++ WLineEdit::setValidator怎么用?C++ WLineEdit::setValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WLineEdit
的用法示例。
在下文中一共展示了WLineEdit::setValidator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addBook
void BasePage::addBook(){
WContainerWidget *container = new WContainerWidget();
Wt::WTemplate *t = new Wt::WTemplate(Wt::WString::tr("addBookForm"));
WLineEdit *editTitle = new WLineEdit(container);
editTitle->setPlaceholderText("title");
t->bindWidget("title", editTitle);
WLineEdit *editAuthor = new WLineEdit(container);
editAuthor->setPlaceholderText("author");
t->bindWidget("author", editAuthor);
WLineEdit *editAuthorYears = new WLineEdit(container);
editAuthorYears->setPlaceholderText("years of life");
t->bindWidget("years", editAuthorYears);
WLineEdit *editGenre = new WLineEdit(container);
editGenre->setPlaceholderText("genre");
t->bindWidget("genre", editGenre);
WLineEdit *editYear = new WLineEdit(container);
editYear->setPlaceholderText("year");
t->bindWidget("year", editYear);
WLineEdit *editSeria = new WLineEdit(container);
editSeria->setPlaceholderText("seria");
t->bindWidget("seria", editSeria);
WLineEdit *editNumOfBooks = new WLineEdit(container);
editNumOfBooks->setPlaceholderText("num of books");
t->bindWidget("numOfBooks", editNumOfBooks);
WLineEdit *editNumInSeria = new WLineEdit(container);
editNumInSeria->setPlaceholderText("number in seria");
t->bindWidget("numInSeria", editNumInSeria);
WLineEdit *editMark = new WLineEdit(container);
editMark->setPlaceholderText("mark");
editMark->setValidator(new Wt::WIntValidator(1, 10));
t->bindWidget("mark", editMark);
WPushButton *button = new WPushButton("Add book", container);
button->setMargin(10, Top | Bottom);
button->clicked().connect(std::bind([=] () {BookManager bm; bm.addBook(editTitle->valueText().toUTF8(),
editAuthor->valueText().toUTF8(),
editAuthorYears->valueText().toUTF8(),
editGenre->valueText().toUTF8(),
intoInt(editYear),
editSeria->valueText().toUTF8(),
intoInt(editNumOfBooks),
intoInt(editNumInSeria),
intoInt(editMark)); }));
t->bindWidget("button", button);
_pagecontent->addWidget(t);
}
示例2: WContainerWidget
ChartSettings::ChartSettings(WCartesian3DChart *chart,
WContainerWidget * parent)
: WContainerWidget(parent),
chart_(chart)
{
WTemplate* template_ = new WTemplate(Wt::WString::tr("chartconfig-template"), this);
WCheckBox *autoRangeX_ = new WCheckBox(this);
template_->bindWidget("xAuto", autoRangeX_);
autoRangeX_->setCheckState(Wt::Checked);
chart_->initLayout();
WLineEdit *xMin_ = new WLineEdit
(Wt::asString(chart_->axis(XAxis_3D).minimum()), this);
template_->bindWidget("xAxisMin", xMin_);
xMin_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
xMin_->setEnabled(false);
WLineEdit *xMax_ = new WLineEdit
(Wt::asString(chart_->axis(XAxis_3D).maximum()), this);
template_->bindWidget("xAxisMax", xMax_);
xMax_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
xMax_->setEnabled(false);
WCheckBox *autoRangeY_ = new WCheckBox(this);
template_->bindWidget("yAuto", autoRangeY_);
autoRangeY_->setCheckState(Wt::Checked);
WLineEdit *yMin_ = new WLineEdit
(Wt::asString(chart_->axis(YAxis_3D).minimum()), this);
template_->bindWidget("yAxisMin", yMin_);
yMin_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
yMin_->setEnabled(false);
WLineEdit *yMax_ = new WLineEdit
(Wt::asString(chart_->axis(YAxis_3D).maximum()), this);
template_->bindWidget("yAxisMax", yMax_);
yMax_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
yMax_->setEnabled(false);
WCheckBox *autoRangeZ_ = new WCheckBox(this);
template_->bindWidget("zAuto", autoRangeZ_);
autoRangeZ_->setCheckState(Wt::Checked);
WLineEdit *zMin_ = new WLineEdit
(Wt::asString(chart_->axis(ZAxis_3D).minimum()), this);
template_->bindWidget("zAxisMin", zMin_);
zMin_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
zMin_->setEnabled(false);
WLineEdit *zMax_ = new WLineEdit
(Wt::asString(chart_->axis(ZAxis_3D).maximum()), this);
template_->bindWidget("zAxisMax", zMax_);
zMax_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
zMax_->setEnabled(false);
WLineEdit *title = new WLineEdit(this);
template_->bindWidget("chartTitle", title);
WCheckBox *enableLegend = new WCheckBox(this);
template_->bindWidget("chartLegend", enableLegend);
WComboBox *legendSide = new WComboBox(this);
legendSide->addItem("Left");
legendSide->addItem("Right");
legendSide->addItem("Top");
legendSide->addItem("Bottom");
template_->bindWidget("legendside", legendSide);
switch (chart_->legendSide()) {
case Left:
legendSide->setCurrentIndex(0); break;
case Right:
legendSide->setCurrentIndex(1); break;
case Top:
legendSide->setCurrentIndex(2); break;
case Bottom:
legendSide->setCurrentIndex(3); break;
default:
break;
}
WComboBox *legendAlignment = new WComboBox(this);
legendAlignment->addItem("Left");
legendAlignment->addItem("Center");
legendAlignment->addItem("Right");
legendAlignment->addItem("Top");
legendAlignment->addItem("Middle");
legendAlignment->addItem("Bottom");
template_->bindWidget("legendalignment", legendAlignment);
switch (chart_->legendAlignment()) {
case AlignLeft:
legendAlignment->setCurrentIndex(0); break;
case AlignCenter:
legendAlignment->setCurrentIndex(1); break;
case AlignRight:
legendAlignment->setCurrentIndex(2); break;
case AlignTop:
legendAlignment->setCurrentIndex(3); break;
case AlignMiddle:
legendAlignment->setCurrentIndex(4); break;
case AlignBottom:
legendAlignment->setCurrentIndex(5); break;
default:
break;
}
WCheckBox *enableGridLines = new WCheckBox(this);
template_->bindWidget("gridlines", enableGridLines);
WLineEdit *widgetWidth = new WLineEdit(Wt::asString(chart_->width().value()), this);
widgetWidth->setValidator(new Wt::WIntValidator(1, 2000));
//.........这里部分代码省略.........