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
3
votes
1 answer

Qt - Convert QDateTime to QJSValue

How can I convert a QDateTime into a QJSValue? Converting in the opposite direction is easy: there is QJSValue::isDate and QJSValue::toDateTime.
kol
  • 27,881
  • 12
  • 83
  • 120
2
votes
1 answer

How to add current time and date widget with PyQt5?

I designed a GUI that opens camera, shows date, time and has QSpinBox. But it shows the date and time according to when I run the application and the time does not advance. The code I have given below works fine. Both the camera start and stop…
tirit
  • 33
  • 2
2
votes
1 answer

How to make QDateTimeEdit widget of qt designer in 24hr clock format

I am working on UI design which I am designing in qt desginer. In qt designer, there is a widget QDateTimeEdit through which we can select the date and time. I have added it and it looks like below: I have added two widgets from start and end date…
S Andrew
  • 5,592
  • 27
  • 115
  • 237
2
votes
2 answers

Qt to QML conversion: QDateTime -> date

So I'm sending a QDateTime to QML in order to display it and do some checkings (ideally I would like to be able to use all javascript date functions like getTime(),getMonth()...), and I realized if I send: QDateTime(2019-10-30 11:15:00.000 CET…
laurapons
  • 971
  • 13
  • 32
2
votes
1 answer

QDateTime custom format escaping symbols

I would like to get a customized QDateTime such as: QString string = "23 April 2012 at 22:51"; QString format = "d MMMM yyyy at hh:mm"; I am unable to as the literal at is not recognized as an 'additional' string but has tokens associated. a -> …
CybeX
  • 2,060
  • 3
  • 48
  • 115
2
votes
2 answers

Qt4 problem with formatting hours in QDateTime

I've a problem with following code: QDateTime test2; test2.setTime_t(25); qDebug() << test2.toString("hh:mm:ss"); this prints "01:00:25" to output instead of 00:00:25. Why is the first hour set to 01 instead of 00 ? I thought that maybe am/pm…
user666491
2
votes
1 answer

PyQtChart not displaying data

I have been trying to build a chart using PyQtChart. I have been following this implementation and it is what I would like to produce. https://doc.qt.io/qt-5/qtcharts-datetimeaxis-example.html The Chart displays but is missing the data and the X…
johnashu
  • 2,167
  • 4
  • 19
  • 44
2
votes
1 answer

QTimeEdit, change only hours?

In my application I have a QTimeEdit, in which I only want to edit the hours. Is it possible to do that? (Disable editing of minutes)
erniberni
  • 313
  • 5
  • 17
2
votes
2 answers

QDateTime::secsTo returns the same value for different QDateTime's

I recently wrote a stopwatch and noticed some strange behavior of QDateTime::secsTo. I'm not sure if it's a bug or a feature (or perhaps I only did a crappy implementation ;-). My stopwatch code can be stripped down to this minimal example to…
Tobias Leupold
  • 1,512
  • 1
  • 16
  • 41
2
votes
2 answers

Are these timezone conversions correct?

I use Qt 5.7.1 on Windows, 64 bits version. In my application, I manage some date time with different time zone. I've recently seen some strange behaviour, and here is a simple code to test it : QDateTime ParisDate(QDate(2016, 1, 20), QTime(2, 0,…
Aurelien
  • 1,032
  • 2
  • 10
  • 24
2
votes
3 answers

How to convert seconds (double) to QDateTime in Qt?

I have a number of seconds stored in a double format (but they are integer values if that's to be concerned). I would like to convert them to a hh:mm:ss format string. How to do that? For example double secs = 120; would be 00:02:00.
Łukasz Przeniosło
  • 2,725
  • 5
  • 38
  • 74
2
votes
2 answers

How to set timezone in Qt?

Can someone show me how to set time zone in Qt? Currently I am using the linux system() call to set the time zone, but this is not reflecting in currentTime() API of Qt. There is a setTimeZone() API in Qt 5 and above but I have no idea how to use…
jxgn
  • 741
  • 2
  • 15
  • 36
2
votes
2 answers

Convert QDate to seconds

I take date from QDateTimeEdit and convert it to seconds like this: import time from datetime import datetime date = self.__ui.dateTimeEdit.date().toString("dd/MM/yy") dateString = str(date) seconds = time.mktime(datetime.strptime(dateString,…
Aleksandar
  • 3,541
  • 4
  • 34
  • 57
2
votes
1 answer

How to add qdate to qtableview

I want to add Qdate to my table say QTableview.The problem is if i convert it into string i can add and retrieve the data.But i want to store as date only in my model. void MainWindow::setUpTabel() { QDateTime myDate; …
anbu selvan
  • 725
  • 3
  • 13
  • 41
2
votes
1 answer

QDataWidgetMapper and QDateEdit values

I have QSqlTableModel with some table, let's suppose that it's a model->setTable("Person"); And also I have QDataWidgetMapper which mapps some widgets (lineedits etc.) to appropriate columns in model. So the problem is in QDateEdit element.…
Daniel
  • 635
  • 1
  • 5
  • 22