[Qt-interest] SOLVED QImageReader cannot detect image format

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Thu May 6 12:27:16 CEST 2010


Guido Seifert wrote on Thursday, May 06, 2010 9:20 AM:

> This is sick. I found the problem. When in the QImageReader docs
> 'filename' is written, 'filename' is meant. NOT an absolute file
> path.

why is this "sick" if someone says "A" and actually means "A" (and not "B")? ;) /foo/bar/barfoo.jpg would be a file PATH for me, barfoo.jpg the file NAME. Also refer to http://doc.trolltech.com/4.6/qfileinfo.html#fileName and http://doc.trolltech.com/4.6/qfileinfo.html#absoluteFilePath.

But I agree with you that this naming is unfortunatelly not entirely consistent through the Qt API: for example http://doc.trolltech.com/4.6/qfile.html#QFile c'tor takes a file NAME, when in fact it is meant to be a PATH. Also http://doc.trolltech.com/4.6/qfile.html#fileName normally returns the entire path, when the file was constructed like:

  QFile file("/foo/bar/barfoo.jpg");
  String fileName = file.fileName(); // returns /foo/bar/barfoo.jpg
  QFileInfo fileInfo(file);
  fileName = fileInfo.fileName(); // returns just (correctly) barfoo.jpg!

But QFile could also be used like this:

  QFile file("barfoo.jpg"); // file name only

So I guess that would operate on the file name in the current working directory (and in this use case the c'tor parameter name fileNAME is justified).

Cheers, Oliver



More information about the Qt-interest-old mailing list