Deprecate one overload of QInputDialog::getDouble() for 5.15
...and merge the two overloads of getDouble() in Qt6 Change-Id: I55faa2ff222b41e48889a0ef14dd00a6da691c36 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
2b0af50c8b
commit
5e83a2eed2
@ -329,7 +329,8 @@ void Dialog::setDouble()
|
|||||||
//! [1]
|
//! [1]
|
||||||
bool ok;
|
bool ok;
|
||||||
double d = QInputDialog::getDouble(this, tr("QInputDialog::getDouble()"),
|
double d = QInputDialog::getDouble(this, tr("QInputDialog::getDouble()"),
|
||||||
tr("Amount:"), 37.56, -10000, 10000, 2, &ok);
|
tr("Amount:"), 37.56, -10000, 10000, 2, &ok,
|
||||||
|
Qt::WindowFlags(), 1);
|
||||||
if (ok)
|
if (ok)
|
||||||
doubleLabel->setText(QString("$%1").arg(d));
|
doubleLabel->setText(QString("$%1").arg(d));
|
||||||
//! [1]
|
//! [1]
|
||||||
|
@ -1349,6 +1349,7 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l
|
|||||||
\sa getText(), getDouble(), getItem(), getMultiLineText()
|
\sa getText(), getDouble(), getItem(), getMultiLineText()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 15)
|
||||||
/*!
|
/*!
|
||||||
Static convenience function to get a floating point number from the user.
|
Static convenience function to get a floating point number from the user.
|
||||||
|
|
||||||
@ -1380,7 +1381,7 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr
|
|||||||
{
|
{
|
||||||
return QInputDialog::getDouble(parent, title, label, value, min, max, decimals, ok, flags, 1.0);
|
return QInputDialog::getDouble(parent, title, label, value, min, max, decimals, ok, flags, 1.0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/*!
|
/*!
|
||||||
\overload
|
\overload
|
||||||
Static convenience function to get a floating point number from the user.
|
Static convenience function to get a floating point number from the user.
|
||||||
|
@ -176,13 +176,24 @@ public:
|
|||||||
static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
|
static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
|
||||||
int minValue = -2147483647, int maxValue = 2147483647,
|
int minValue = -2147483647, int maxValue = 2147483647,
|
||||||
int step = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
|
int step = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 15)
|
||||||
|
QT_DEPRECATED_X("This overload is deprecated. Use the overload that takes step as a final argument")
|
||||||
static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
|
static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
|
||||||
double minValue = -2147483647, double maxValue = 2147483647,
|
double minValue = -2147483647, double maxValue = 2147483647,
|
||||||
int decimals = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
|
int decimals = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||||
|
#endif
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
|
||||||
|
double minValue = -2147483647, double maxValue = 2147483647,
|
||||||
|
int decimals = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
|
||||||
|
double step = 1);
|
||||||
|
#else
|
||||||
// ### Qt 6: merge overloads
|
// ### Qt 6: merge overloads
|
||||||
static double getDouble(QWidget *parent, const QString &title, const QString &label, double value,
|
static double getDouble(QWidget *parent, const QString &title, const QString &label, double value,
|
||||||
double minValue, double maxValue, int decimals, bool *ok, Qt::WindowFlags flags,
|
double minValue, double maxValue, int decimals, bool *ok, Qt::WindowFlags flags,
|
||||||
double step);
|
double step);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if QT_DEPRECATED_SINCE(5, 0)
|
#if QT_DEPRECATED_SINCE(5, 0)
|
||||||
QT_DEPRECATED static inline int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
|
QT_DEPRECATED static inline int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
|
||||||
|
@ -326,7 +326,7 @@ void tst_QInputDialog::getDouble()
|
|||||||
// rounded off to 10.03)
|
// rounded off to 10.03)
|
||||||
const double value = static_cast<int>(min + (max - min) / 2);
|
const double value = static_cast<int>(min + (max - min) / 2);
|
||||||
const double result =
|
const double result =
|
||||||
QInputDialog::getDouble(parent, "", "", value, min, max, decimals, &ok);
|
QInputDialog::getDouble(parent, "", "", value, min, max, decimals, &ok, Qt::WindowFlags(), 1);
|
||||||
QVERIFY(ok);
|
QVERIFY(ok);
|
||||||
QCOMPARE(result, value);
|
QCOMPARE(result, value);
|
||||||
delete parent;
|
delete parent;
|
||||||
@ -395,7 +395,8 @@ void tst_QInputDialog::taskQTBUG_54693_crashWhenParentIsDeletedWhileDialogIsOpen
|
|||||||
const double initial = 7;
|
const double initial = 7;
|
||||||
QAutoPointer<SelfDestructParent> dialog(new SelfDestructParent);
|
QAutoPointer<SelfDestructParent> dialog(new SelfDestructParent);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
const double result = QInputDialog::getDouble(dialog.get(), "Title", "Label", initial, -10, +10, 2, &ok);
|
const double result = QInputDialog::getDouble(dialog.get(), "Title", "Label", initial, -10, +10, 2, &ok,
|
||||||
|
Qt::WindowFlags(), 1);
|
||||||
QVERIFY(!dialog);
|
QVERIFY(!dialog);
|
||||||
QVERIFY(!ok);
|
QVERIFY(!ok);
|
||||||
QCOMPARE(result, initial);
|
QCOMPARE(result, initial);
|
||||||
@ -411,7 +412,7 @@ void tst_QInputDialog::task255502getDouble()
|
|||||||
bool ok = false;
|
bool ok = false;
|
||||||
const double value = 0.001;
|
const double value = 0.001;
|
||||||
const double result =
|
const double result =
|
||||||
QInputDialog::getDouble(parent, "", "", value, -1, 1, 4, &ok);
|
QInputDialog::getDouble(parent, "", "", value, -1, 1, 4, &ok, Qt::WindowFlags(), 1);
|
||||||
QVERIFY(ok);
|
QVERIFY(ok);
|
||||||
QCOMPARE(result, value);
|
QCOMPARE(result, value);
|
||||||
delete parent;
|
delete parent;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user