0

I made a simple app displaying local time, utc time and the timezone offset. By default my qt app uses my local timezone "Europe/Amsterdam". But i want it to change when a new timezone is selected with the QCombobox which has a list of all the iana timezoneid's. But i can't find a method/function to change the default timezone to let say "Europe/Berlin" or any other timezoneid.

enter image description here

Esocoder
  • 1,032
  • 1
  • 19
  • 40

1 Answers1

0

Eventually found the solution for my question. It seems i had to send a timezoneid with QDatime object:

QString comboxs = ui->comboBox->currentText();

QByteArray timezoneQstring = comboxs.toLocal8Bit();

timezoneids = timezoneQstring.data();

QDateTime timeobj = QDateTime(QDate(2019, 11, 5), QTime(20,28), QTimeZone(timezoneids));
Esocoder
  • 1,032
  • 1
  • 19
  • 40