V
V
Vladimir Korshunov2021-12-28 20:35:36
Qt
Vladimir Korshunov, 2021-12-28 20:35:36

How to copy Word workspace?

I'm trying to copy a Word workspace and I'm having trouble. As a basis I use QTextEdit.
1) 14th text size, set like this:

QFont timesNewRoman("Times New Roman", 14);
    inputTextEdit->document()->setDefaultFont(timesNewRoman);

different from the 14th size, which I see in the Word. It differs somewhere by three points, that is, in order for the text on the screen to be the same size, I need to set 17, not 14. What could be the problem here?
2) I don't understand at all how Word figures out what width and height of the workspace to draw. Let's say I want to write on A4, it's 21x29.7 cm. From this information, I can only pull out the aspect ratio, how to get exactly the resolution is not very clear to me. The problem is that what we see in Word, we then see on a real sheet - how can I achieve the same in my program? That is, if I have 30 F letters in a line on my screen, then there were 30 of them on the real A4. this function is the size of a pixel on the screen 160dpi, that is, 40x40 logical pixels give one real square inch, => 40 logical pixels give a regular inch. There are 8.27 inches in 21 centimeters (from A4), => the desired width will be 40 * 8.27= 330.8 logical pixels. Now let's convert these pixels back to real ones by multiplying by the ratio we got earlier. My devicePixelRatio() function returns 2, that is, the actual width is 330.8 * 2 = 662 pixels. In reality, it's not even close, well, I tried.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question