Important: Please read the Qt Code of Conduct -

QFont - Text size.

  • How can I get the text size in pixels? I looked a bit at the QFont class.

    For example, I make a QFont
    pSmallThickFont=new QFont("Arial", 14, -1, false);

    and I make a QLabel
    STATICInformation1=new QLabel(this);
    STATICInformation1->setGeometry(xSPosition1, yPosition1, 250, 22);
    STATICInformation1→setText(tr("Some text goes here"));

    How many pixels would "Some text goes here" occupy?

    Let’s forget about scaling on high DPI screens for the moment.

  • Lifetime Qt Champion

    You can take a look at QFontMetrics

Log in to reply