Questions tagged [qdatetime]

A QDateTime is a class from the Qt toolkit which provides functions for working with both dates and times.

A QDateTime object is a combination of the QDate and QTime classes which contains information about a calendar date and clock time. It can read the current date and time from the system clock, and also provides functions for comparing, formatting and parsing date/times, and for performing basic date/time calculations.

The official documentation can be found here.

88 questions
2
votes
1 answer

QDateTimeEdit: rollback from 59 to 00 or vice-versa in hours/minute/second

How can I rollback hour/min/sec from 59 to 00 or vice versa. Actually QDateTimeEdit doesn't allow it by default and it get stuck after reaching maximum value of 59 if tried pressing up arrow, and same for minimum value 00.
1
vote
1 answer

PyQt QDateEdit Selection Issues

I have a PyQt application, which contains a QDateEdit. I've set a limit to the date range which can be selected, which is a short range over the boundary of a month, e.g. 28/01/2011 to 02/02/2011. This seems to break the QDateEdit, because you…
paulmdavies
  • 1,248
  • 3
  • 12
  • 28
1
vote
1 answer

QDateTime::fromString(, "ddd MMM d yy HH:mm") returns invalid

I'm trying to parse a QString containing a custom datetime format as follows "ddd MMM d yy HH:mm". I have the following code which produces an invalid datetime object: QString format = "ddd MMM d yy HH:mm"; QString date = "Tue May 2 23…
Yildirim
  • 25
  • 4
1
vote
1 answer

C++ reliable way to get QDateTime for buildtime

Previously I had a question about __DATE__ I want to use __DATE__ to get the build time. The product will be compiled on systems with different locale. Is the format for __DATE__ always the same? My goal is to get the buildtime from __DATE__ and i…
Sven van den Boogaart
  • 11,833
  • 21
  • 86
  • 169
1
vote
1 answer

No matching function for call to 'QtCharts::QLineSeries::append(int&,Date&)

The line m_total_hour_series->append(pair.first, pair.second); is the source of the problem. The error message says: No matching function for call to 'QtCharts::QLineSeries::append(int&,Date&)' I have looked at examples of the line chart and looked…
Debra
  • 11
  • 2
1
vote
0 answers

How to get the difference between tow QDateTimes?

I want to get the milliseconds difference between two QDateTimes. My code is the following: QDateTime t1 = QDateTime(); t1 = QDateTime::fromString("2019-12-16 23:59:59.974", "yyyy-MM-dd HH:mm:ss.zzz"); QDateTime t2 = QDateTime(); t2 =…
1
vote
2 answers

Issue with QMap and QDateTime as key

I'm using Qt 4.8.6 msvc 2010. I'm working on a software (this is done before Qt5, I'm supporting now). I have used a map: QMap dateTime After I insert some data to this map (for example with 5000 of data) and I want to get a…
Mosi
  • 1,178
  • 2
  • 12
  • 30
1
vote
1 answer

Subtract 40 minutes from current time

I would like to use QDateTime to represent the value of 40 minutes less than the current time as a string. QDateTime time = QDateTime::currentDateTime() - QDateTime::fromString(QDateTime::currentDateTime().toString("yy/MM/dd hh:40:00"), "yy/MM/dd…
a101a78
  • 27
  • 6
1
vote
1 answer

Converting QString containing PostgreSQL timestamp to QDateTime

I'm having trouble with a seemingly very simple problem: I want to get a QDateTime from a QString containing a timestamp. I got the timestamp from PostgreSQL, but it doesn't matter. Here is the code that does not work: QString timestamp =…
Joseph S.
  • 475
  • 1
  • 6
  • 11
1
vote
1 answer

QDateTimeEdit select last day of each month

I have a QDateTimeEdit and user should select a date with it. However, I need to select the last day of each month. So, for example if user select 3rd of March, I should set date to 31th of March. I try to do this in the slot of dateChanged(const…
nabroyan
  • 3,225
  • 6
  • 37
  • 56
1
vote
2 answers

Qt. QDateTime unpredictable behaviour with timezones and addSecs

I can't realize what's wrong. QTimeZone zone1(QTimeZone("Europe/Moscow")); QTimeZone zone2(QTimeZone("Asia/Yekaterinburg")); QDateTime test = QDateTime(QDate(2016, 11, 11), QTime(15,00), zone1); qDebug() << test;//QDateTime(2016-11-11 15:00:00.000…
Atnes Ness
  • 13
  • 4
1
vote
1 answer

Qt QDateTime microsecond accuracy

I am using Qt5.6, MSVC2013 32bit on Windows as well as Qt5.4, 64 bit on Ubuntu. I am trying to parse Journal syslog to convert _SOURCE_REALTIME_TIMESTAMP into human readable text. Somehow the millisecond is all 0. Wondering what is correct way to…
thsieh
  • 620
  • 8
  • 24
1
vote
2 answers

Get local time in seconds using Qt

I am stuck with this problem. I already got the currentUTCtime in seconds from the QDateTime. Problem is, I can't find a possible way to convert this into the local time in seconds. There are some QDate functions like toLocalTime() which just don't…
MuchWow
  • 35
  • 2
  • 7
1
vote
4 answers

Convert System::Datetime to QDateTime

How can I convert System::Datetime to QDateTime?
Ayoub
  • 361
  • 4
  • 15
1
vote
1 answer

QwtPlot showing the wrong date/time

I'm using QwtDateScaleDraw in Qt to plot a QDateTime at the X-axis of a graph. I use this command to convert the QDateTime to a QwtDate::Double: tempData->append( QPointF( QwtDate::toDouble( date.at(var) ), data.at(var) ) ); The first date/time…
KelvinS
  • 2,870
  • 8
  • 34
  • 67