Jans Raberta
Jans Raberta

Reputation: 11

QT get jpeg exif metadata for DateTime

I want to get the EXIF metadata of my JPEG images (only DateTime). I want to use the standard Qt functions if possible. I use Qt Creator on Windows.

I tried to use QMediaMetaData::DateTimeOriginal() but I don't know how to use it. So I can't compile it. I didn't find any examples for images.

My attempt:

QString info;
info = QMediaMetaData::DateTimeOriginal(PathtoImageFile);

The error message is:

...mainwindow.cpp:80: Fehler: no match for call to '(const QString) (QString&)'
             info = QMediaMetaData::DateTimeOriginal(PathtoImageFile);
                                                              ^

What am I doing wrong, and what's the correct way to obtain this metadata?

Note: I have ensured that the multimedia library is included/linked:

QT += multimedia

Upvotes: 1

Views: 2249

Answers (1)

Toby Speight
Toby Speight

Reputation: 30922

The documentation shows that QMediaMetaData::DateTimeOriginal isn't a method; it's a string constant that can be used with the QMediaObject::metaData() method. So you want something more like

QDateTime t = mediaObject->metaData(QMediaMetaData::DateTimeOriginal).toDateTime();

Upvotes: 1

Related Questions