Question

I have a QPainter object and would like to obtain the string that is drawn whenever QPainter::drawText is called, as I would if I could connect a slot to that signal (which doesn't exist, so I can't). What would be the best way to do this? I have read some stuff about redirecting the drawText method to a custom one using the setProperty method, and passing it a pointer to drawText, but I've never tried it, and it seems like overkill to me.. Anyone have a better idea about how to obtain the String of text that is drawn by drawText?

Edit: It would also be ok if instead of getting the text form the painter, we get it from the PaintEngine

Any help is appreciated, Thanks

Was it helpful?

Solution

I guess the only reliable way is to subclass QPainter, reimplement the drawText() method and add some debug text in your own class. I doubt QPainter has any facilities to capture a signal or something, since most of the drawing methods are speed critical.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top