I place the images on a QScene and then save the QScene itself as an image. I need the size of this image to match the size of an A4 sheet. If I understand correctly, depending on the monitor, the scene size in pixels must be set different, because there are different pixel sizes. In this case, it is necessary to read the pixel size each time and, based on this, set the size of the scene? or can it be done somehow else?

    2 answers 2

    The whole QGraphicsScene able to scale, this time.

    Pixel size cannot be known by software - any nonsense can be stored in the EDID.

    • I do not quite understand. Do you mean that it is impossible to control the size of the stage in such a case, so that it is equal, conditionally, to the size of A4 paper? - jesuscrew77
    • @ jesuscrew77 yes. You do not know how many pixels are in inches on the connected monitor. And you can not know. Only if the user himself measures the screen. - gbg
    • thank. and one more question. if I place several images of QImage::Format_Mono on the scene, and then save the scene itself as an image of the same format, then the quality of these images will remain the same, being in this form? - jesuscrew77
    • @ jesuscrew77 depends on the method and format of saving - gbg
    • I want to save in .tiff or .raw format, as for the method, then if it doesn’t bother you, tell me how to keep it so that the quality remains the same? - jesuscrew77

    Dimensions A4 - 210mm x 297mm. I calculated this way:

     #include <QScreen> float pixelPerMm = QApplication::screens().at(0)->logicalDotsPerInch()/2.54/10; float widthA4 = pixelPerMm*210;//Ширина float widthA4 = pixelPerMm*297;//Высота 

    Take the logical DPI of the main monitor, and since resolution is the number of pixels per inch, and an inch is 2.54 cm, then we do the translation in cm and then the translation in mm and get the pixels per mm.

    • If this DPI had to do with reality, there would be no price for it. It is configured by the user in the control panel window. - gbg
    • @gbg Well, there is also the receipt of a physical dipia, the physicalDotsPerInch method, but again, you can always minus, but does YOU have a working version? - Vyacheslav Savchenko
    • There is no working option - the monitor does not inform the video card about the size of its pixel through EDID. - gbg
    • @gbg, if desired, you can drag the monitor data from the registry, but the question is why? in meticulous accuracy, I do not mean the point, and my version is quite working. - Vyacheslav Savchenko