Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Determing a paint device
QtWS25 Last Chance

Determing a paint device

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    steno
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #3

        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.

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

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

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • S Offline
            S Offline
            steno
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dangelog
              wrote on last edited by
              #6

              Then you can use type(). :)

              Software Engineer
              KDAB (UK) Ltd., a KDAB Group company

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved