Obsolete Members for QDateTime
QDateTime クラスの以下のメンバーは非推奨となっています。これらは、古いソースコードが動作し続けるように提供されているものです。新しいコードでの使用は強く推奨しません。
パブリック関数
(deprecated in 6.9) | QDateTime(QDate date, QTime time, Qt::TimeSpec spec, int offsetSeconds = 0) |
(deprecated in 6.9) void | setOffsetFromUtc(int offsetSeconds) |
(deprecated in 6.9) void | setTimeSpec(Qt::TimeSpec spec) |
(deprecated in 6.9) QDateTime | toTimeSpec(Qt::TimeSpec spec) const |
静的パブリックメンバー
(deprecated in 6.9) QDateTime | fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetSeconds = 0) |
(deprecated in 6.9) QDateTime | fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spec, int offsetSeconds = 0) |
メンバー関数のドキュメント
[deprecated in 6.9] QDateTime::QDateTime(QDate date, QTime time, Qt::TimeSpec spec, int offsetSeconds = 0)
この関数はバージョン6.9以降、非推奨となっています。新しいコードでの使用は強く推奨しません。
QDateTime(date, time) またはQDateTime(date, time, QTimeZone::fromSecondsAheadOfUtc(offsetSeconds)) を使用してください。
指定された `date ` および `time` を使用し、spec で示される時刻表現と `offsetSeconds ` 秒に基づいて、datetime オブジェクトを生成します。
date が有効で、time が無効な場合、時刻は午前0時に設定されます。
spec がQt::OffsetFromUTC でない場合、offsetSeconds は無視されます。spec がQt::OffsetFromUTC で、offsetSeconds が 0 の場合、timeSpec() はQt::UTC 、すなわちオフセット 0 秒に設定されます。
spec がQt::TimeZone の場合、specはQt::LocalTime 、つまり現在のシステムタイムゾーンに設定されます。Qt::TimeZone の日時を作成するには、適切なコンストラクタを使用してください。
date がQDateTimeで表現可能な日付の範囲外にある場合、結果は無効となります。spec がQt::LocalTime であり、かつシステムのタイムゾーンが指定された日付と時刻を飛び越えている場合、結果は無効となります。
[static, deprecated in 6.9] QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetSeconds = 0)
この関数はバージョン 6.9 以降、非推奨となっています。新しいコードでの使用は強く推奨しません。
代わりに `QTimeZone ` を渡すか、spec および `offsetSeconds` を省略してください。
spec およびoffsetSeconds で指定された通り、1970年の開始時刻(UTC)から指定されたミリ秒数msecs 経過した時点を表す datetime を返します。
msecs の値の中には、QDateTime の有効範囲外となるもの(負の値および正の値)が含まれる可能性があることに注意してください。これらの値に対して、この関数の挙動は未定義となります。
spec がQt::OffsetFromUTC でない場合、offsetSeconds は無視されます。spec がQt::OffsetFromUTC で、offsetSeconds が0の場合、UTCのオフセットは0であるため、Qt::UTC がspec として使用されます。
spec がQt::TimeZone の場合、代わりにQt::LocalTime が使用されます。これは、現在のシステムタイムゾーンを使用することと同等ですが(表現方法が異なります)。
この関数は、QDateTime::fromMSecsSinceEpoch() をオーバーロードします。
fromSecsSinceEpoch()、toMSecsSinceEpoch()、およびsetMSecsSinceEpoch()も参照してください 。
[static, deprecated in 6.9] QDateTime QDateTime::fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spec, int offsetSeconds = 0)
この関数はバージョン 6.9 以降、非推奨となっています。新しいコードでの使用は強くお勧めしません。
代わりに `QTimeZone ` を渡すか、`spec ` および `offsetSeconds` を省略してください。
spec およびoffsetSeconds で指定されたとおりに記述された、1970年の開始時刻(UTC)から指定された秒数secs 経過した時点を表す datetime を返します。
secs の値には、QDateTime の有効範囲外となるもの(負の値および正の値)が含まれる可能性があることに注意してください。これらの値に対して、この関数の挙動は未定義となります。
spec がQt::OffsetFromUTC と異なる場合、offsetSeconds は無視されます。spec がQt::OffsetFromUTC で、offsetSeconds が 0 の場合、UTC のオフセットはゼロであるため、Qt::UTC がspec として使用されます。
spec がQt::TimeZone である場合、代わりにQt::LocalTime が使用されます。これは、現在のシステムタイムゾーンを使用することと同等ですが(表現方法は異なります)。
この関数は `QDateTime::fromSecsSinceEpoch` をオーバーロードします。
fromMSecsSinceEpoch()、toSecsSinceEpoch()、およびsetSecsSinceEpoch()も参照してください 。
[deprecated in 6.9] void QDateTime::setOffsetFromUtc(int offsetSeconds)
この関数はバージョン 6.9 以降、非推奨となっています。新しいコードでの使用は強く推奨しません。
代わりに `setTimeZone(QTimeZone::fromSecondsAheadOfUtc(offsetSeconds))` を使用してください。
timeSpec() をQt::OffsetFromUTC に、オフセットをoffsetSeconds に設定します。datetime は別の時点を指している場合があります。
オフセットの最大値および最小値は、正または負の14時間です。offsetSeconds がこの範囲を超えるか下回る場合、結果は未定義となります。
offsetSeconds が 0 の場合、timeSpec() はQt::UTC に設定されます。
setTimeZone()、isValid()、offsetFromUtc()、およびtoOffsetFromUtc()も参照してください 。
[deprecated in 6.9] void QDateTime::setTimeSpec(Qt::TimeSpec spec)
この関数はバージョン6.9以降で非推奨となっています。新しいコードでの使用は強く推奨しません。
代わりに `setTimeZone()` を使用してください。
このdatetimeで使用される時刻の指定形式をspec に設定します。datetimeは別の時点を指している可能性があります。
spec がQt::OffsetFromUTC の場合、timeSpec()はQt::UTC に設定されます。つまり、実効オフセットは0となります。
spec がQt::TimeZone の場合、Qt::LocalTime は に設定されます。つまり、現在のシステムタイムゾーンとなります。
例:
QDateTime local(QDateTime::currentDateTime());
qDebug() << "Local time is:" << local;
QDateTime UTC(local);
UTC.setTimeSpec(Qt::UTC);
qDebug() << "UTC time is:" << UTC;
qDebug() << "There are" << local.secsTo(UTC) << "seconds difference between the datetimes.";setTimeZone()、timeSpec()、toTimeSpec()、setDate()、およびsetTime()も参照してください 。
[deprecated in 6.9] QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const
この関数はバージョン 6.9 以降、非推奨となっています。新しいコードでの使用は強くお勧めしません。
代わりに `toTimeZone()` を使用してください。
このdatetimeのコピーを、指定された時刻spec に変換して返します。
結果は、この datetime と同じ時点を表し、これと等しくなります。
spec が `Qt::OffsetFromUTC ` の場合、結果は `Qt::UTC` に設定されます。UTC からの固定オフセットに設定するには、toTimeZone() またはtoOffsetFromUtc() を使用してください。
spec がQt::TimeZone の場合、Qt::LocalTime 、つまりローカルのタイムゾーンに設定されます。指定したタイムゾーンを設定するには、toTimeZone() を使用してください。
例:
QDateTime local(QDateTime::currentDateTime());
QDateTime UTC(local.toTimeSpec(Qt::UTC));
qDebug() << "Local time is:" << local;
qDebug() << "UTC time is:" << UTC;
qDebug() << "No difference between times:" << local.secsTo(UTC);setTimeSpec()、timeSpec()、およびtoTimeZone()も参照してください 。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.