How to get screen size in Qt

Qt includes a very simple method to get the size of the screen (width and height). Here it is:

QSize size = qApp->screens()[0]->size();

Note that this function works perfectly in Android and iOS too.

Another thing to note is that if you replace [0] with 1, 2, 3, … you can access other monitors (if there are any) on desktop computers.



How to correctly read Mat images with special characters in filename

You might have noticed that trying to read images that have special characters (such as Ü, Ö or other non-Ascii characters) with imread function in  OpenCV will lead to crash. I noticed this while trying to open files with special Turkish characters (but I assume it is the same with Spanish, French, German or any other languages.) If you are using Qt, you are lucky because there is a workaround.

Continue reading “How to correctly read Mat images with special characters in filename”

How to read image orientation in Qt (Using stored EXIF)

Updated: QImageReader class in Qt has a new method (introduced in Qt 5.5) named transformation() which you can use for this purpose but this article still applies if you are not using 5.5 or having problems with QImageRaader. Also it is a useful example on how to use GDI in Qt.

You might have also noticed that Qt reads jpg, tif and other types of images that it supports without paying any attention to EXIF information stored in them. EXIF meta data contains highly valuable information about the characteristics of a photograph. Let’s say you want to read an image file into QImage and do some process over it. It is crucial to know what type of orientation the image needs to go through right after reading it.

Continue reading “How to read image orientation in Qt (Using stored EXIF)”