本文整理汇总了C++中QLocale::toFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocale::toFloat方法的具体用法?C++ QLocale::toFloat怎么用?C++ QLocale::toFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLocale
的用法示例。
在下文中一共展示了QLocale::toFloat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_generateRDFBtn_clicked
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatsGenRDFWidget::on_generateRDFBtn_clicked()
{
QLocale loc = QLocale::system();
// Generate the ODF Data from the current values in the ODFTableModel
bool ok = false;
float minDist = loc.toFloat(minDistLE->text(), &ok);
float maxDist = loc.toFloat(maxDistLE->text(), &ok);
int numBins = numBinsLE->text().toInt(&ok);
std::vector<float> boxDims(3);
boxDims[0] = loc.toFloat(BoxSizeXLE->text(), &ok);
boxDims[1] = loc.toFloat(BoxSizeYLE->text(), &ok);
boxDims[2] = loc.toFloat(BoxSizeZLE->text(), &ok);
std::vector<float> boxRes(3);
boxRes[0] = 0.1f;
boxRes[1] = 0.1f;
boxRes[2] = 0.1f;
// Generate the RDF Frequencies
std::vector<float> rdfFrequencies = RadialDistributionFunction::GenerateRandomDistribution(minDist, maxDist, numBins, boxDims, boxRes);
QVector<float> qFreq = QVector<float>::fromStdVector(rdfFrequencies);
// Update the Table model with the latest values
m_RDFTableModel->setTableData(qFreq);
// Update the Qwt plot with the correct values
updateRDFPlot(qFreq);
emit rdfParametersChanged();
}
示例2: gatherSizeDistributionFromGui
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int PrecipitatePhaseWidget::gatherSizeDistributionFromGui(float& mu, float& sigma, float& minCutOff, float& maxCutOff, float& stepSize)
{
QLocale loc = QLocale::system();
bool ok = false;
mu = loc.toFloat(m_Mu_SizeDistribution->text(), &ok);
if (ok == false)
{
return 0;
}
sigma = loc.toFloat(m_Sigma_SizeDistribution->text(), &ok);
if (ok == false)
{
return 0;
}
minCutOff = loc.toFloat(m_MinSigmaCutOff->text(), &ok);
if (ok == false)
{
return 0;
}
maxCutOff = loc.toFloat(m_MaxSigmaCutOff->text(), &ok);
if (ok == false)
{
return 0;
}
stepSize = loc.toFloat(m_BinStepSize->text(), &ok);
if (ok == false)
{
return 0;
}
return 1;
}
示例3: rgb
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void FloatVec3Widget::filterNeedsInputParameters(AbstractFilter* filter)
{
bool ok = false;
FloatVec3_t defValue = m_FilterParameter->getDefaultValue().value<FloatVec3_t>();
FloatVec3_t data;
QLocale loc;
data.x = loc.toFloat(xData->text(), &ok);
if(!ok)
{
errorLabel->setStyleSheet(QString::fromLatin1("color: rgb(255, 0, 0);"));
errorLabel->setText("X Value entered is beyond the representable range for a double.\nThe filter will use the default value of " + getFilterParameter()->getDefaultValue().toString());
errorLabel->show();
DREAM3DStyles::LineEditErrorStyle(xData);
data.x = defValue.x;
}
data.y = loc.toFloat(yData->text(), &ok);
if(!ok)
{
errorLabel->setStyleSheet(QString::fromLatin1("color: rgb(255, 0, 0);"));
errorLabel->setText("Y Value entered is beyond the representable range for a double.\nThe filter will use the default value of " + getFilterParameter()->getDefaultValue().toString());
errorLabel->show();
DREAM3DStyles::LineEditErrorStyle(xData);
data.y = defValue.y;
}
data.z = loc.toFloat(zData->text(), &ok);
if(!ok)
{
errorLabel->setStyleSheet(QString::fromLatin1("color: rgb(255, 0, 0);"));
errorLabel->setText("Z Value entered is beyond the representable range for a double.\nThe filter will use the default value of " + getFilterParameter()->getDefaultValue().toString());
errorLabel->show();
DREAM3DStyles::LineEditErrorStyle(zData);
data.z = defValue.z;
}
QVariant v;
v.setValue(data);
ok = filter->setProperty(PROPERTY_NAME_AS_CHAR, v);
if(false == ok)
{
FilterParameterWidgetsDialogs::ShowCouldNotSetFilterParameter(getFilter(), getFilterParameter());
}
}
示例4: paste
void Plot::paste()
{
QLocale l;
QClipboard *clipboard = QApplication::clipboard();
QString text = clipboard->text();
if(!text.isEmpty()) {
QList<QString> items = text.split('\n');
QList<float> values;
for(int i = 0; i < items.count(); i++) {
values.append(l.toFloat(items[i]));
}
this->detachItems();
// Insert new curves
curve = new QwtPlotCurve( "y = sin(x)" );
curve->setRenderHint( QwtPlotItem::RenderAntialiased );
curve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
curve->setPen( Qt::red );
curve->attach( this );
Data* data = new Data(&values);
curve->setData(data);
setAxisScale( yLeft, data->yMin, data->yMax);
setAxisScale( xBottom, data->xMin, data->xMax);
QwtPlotGrid* grid = new QwtPlotGrid();
grid->setPen(Qt::black, 0.1, Qt::DashLine);
grid->attach(this);
}
}
示例5: getPhaseFraction
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
float EditPhaseDialog::getPhaseFraction()
{
bool ok = false;
QLocale loc = QLocale::system();
float d = loc.toFloat(phaseFraction->text(), &ok);
if (ok) { return d; }
return -1.0;
}
示例6: on_phaseFraction_textChanged
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void EditPhaseDialog::on_phaseFraction_textChanged(const QString& string)
{
bool ok = false;
QLocale loc = QLocale::system();
float d = loc.toFloat(phaseFraction->text(), &ok);
if (ok)
{
float total = d + m_OtherPhaseFractions;
total = d / total;
calcPhaseFraction->setText(QString::number(total));
}
}
示例7: updateRDFPlot
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatsGenRDFWidget::updateRDFPlot(QVector<float>& freqs)
{
// These are the output vectors
QwtArray<double> xD(static_cast<int>(freqs.size()));
QwtArray<double> yD(static_cast<int>(freqs.size()));
QLocale loc = QLocale::system();
bool ok = false;
float minDist = loc.toFloat(minDistLE->text(), &ok);
float maxDist = loc.toFloat(maxDistLE->text(), &ok);
const int numValues = freqs.size();
float increment = (maxDist - minDist) / numValues;
double pos = minDist;
for (qint32 i = 0; i < numValues; ++i)
{
xD[i] = pos;
yD[i] = static_cast<double>(freqs.at(i));
pos = pos + increment;
}
// This will actually plot the XY data in the Qwt plot widget
QwtPlotCurve* curve = m_PlotCurve;
#if QWT_VERSION >= 0x060000
curve->setSamples(xD, yD);
#else
curve->setData(xD, yD);
#endif
curve->setStyle(QwtPlotCurve::Lines);
//Use Antialiasing to improve plot render quality
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
QPen pen;
pen.setColor(Qt::white);
pen.setWidth(2);
curve->setPen(pen);//Set colour and thickness for drawing the curve
curve->attach(m_RDFPlot);
m_RDFPlot->replot();
}