Determing a paint device
-
wrote on 23 Sept 2011, 18:26 last edited by
I couldn't find anything, but I want to make sure I didn't over look anything. In a widget's paintEvent, can you find out what you are painting to? ie a image, screen or printer?
-
wrote on 23 Sept 2011, 18:33 last edited by
You could try dynamic casting the paintDevice that you can get from QPainter to one of the possible subclasses of QPaintDevice, and checking if you get a non-0 result?
-
wrote on 23 Sept 2011, 19:03 last edited by
But ensure, that Qt was build using RTTI, which is switched off by default. qobject_cast does not work, as QPaintDevice is not a subclass of QObject.
-
wrote on 23 Sept 2011, 22:09 last edited by
Grab the QPaintDevice from the QPainter, then the QPaintEngine using QPaintDevice::paintEngine(), and finally use type() to figure it out.
(BTW, are we talking about things like QWidget::render? If not, what's exactly your use case?)
-
wrote on 26 Sept 2011, 15:02 last edited by
[quote author="peppe" date="1316815782"](BTW, are we talking about things like QWidget::render? If not, what's exactly your use case?)[/quote]
Correct, I'm trying to prevent certian attributes from being painted when painting to a printer in a custom widet that I'm working on.
-
wrote on 26 Sept 2011, 18:03 last edited by
Then you can use type(). :)
1/6