| 287 | #endif |
| 288 | |
| 289 | QSpinBox* create(int min, int max, const QString &unit, int step) |
| 290 | { |
| 291 | auto box = new QSpinBox(); |
| 292 | box->setRange(min, max); |
| 293 | const auto space = QLatin1Char{' '}; |
| 294 | if (unit.startsWith(space)) |
| 295 | box->setSuffix(unit); |
| 296 | else if (unit.length() > 0) |
| 297 | box->setSuffix(space + unit); |
| 298 | if (step > 0) |
| 299 | box->setSingleStep(step); |
| 300 | #ifndef NDEBUG |
| 301 | if (countDigits(min, box->locale()) > max_digits()) |
| 302 | qWarning("Util::SpinBox::create() will create " |
| 303 | "a very large widget because of min=%s", |
| 304 | QByteArray::number(min).constData()); |
| 305 | if (countDigits(max, box->locale()) > max_digits()) |
| 306 | qWarning("Util::SpinBox::create() will create " |
| 307 | "a very large widget because of max=%s", |
| 308 | QByteArray::number(max).constData()); |
| 309 | #endif |
| 310 | return box; |
| 311 | } |
| 312 | |
| 313 | QDoubleSpinBox* create(int decimals, double min, double max, const QString &unit, double step) |
| 314 | { |
no test coverage detected