Determing a paint device



  • 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?



  • 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?



  • 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.



  • 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?)



  • [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.



  • Then you can use type(). :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.