Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QPainter width and height

Is there any chance to find out the size of the QPainter? I am using QPainter for drawing the whole graphic interface for a mobile app. The problem is that certain application overlay the window with menu which size is different for every device, thus making things nearly impossible! Are there any possibilities to do it instead of knowing QPainter size?

EDIT: simple width() and height() works!

like image 776
Blackie123 Avatar asked Aug 03 '11 13:08

Blackie123


People also ask

What is QPainter?

QPainter is the class used to perform drawing operations. QPaintDevice represents a device that can be painted on using a QPainter . QPaintEngine provides the interface that the painter uses to draw onto different types of devices.

How do you draw text in Qt?

You can use this: QPainter painter(this); painter. setPen(Qt::yellow); painter. drawText(0, 20, "One"); painter.


1 Answers

You have to look at the size of the QPaintDevice attached to the QPainter

painter->device()->width();
like image 72
Alessandro Pezzato Avatar answered Nov 03 '22 07:11

Alessandro Pezzato