April 2018
Intermediate to advanced
404 pages
8h 27m
English
Additionally, you can also draw text using the QPainterclass. All you need to do is to call QPainter::setFont() to set the font properties before calling QPainter::drawText(), like so:
QPainter painter;
painter.begin(this);
// Draw Text
painter.setFont(QFont("Times", 14, QFont::Bold));
painter.drawText(QPoint(20, 30), "Testing");
// Draw Line
painter.drawLine(QPoint(50, 60), QPoint(100, 100))
The setFont() function is optional as you will get a default font if you don't specify it. Once you're done, build and run the program. You should see the word Hello World! displayed in the window:

As you can see here, the vector shapes ...
Read now
Unlock full access