Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Determing a paint device

    General and Desktop
    4
    6
    2297
    Loading More Posts
    • 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
      steno 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?

      1 Reply Last reply Reply Quote 0
      • A
        andre 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?

        1 Reply Last reply Reply Quote 0
        • G
          giesbert 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.

          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 Reply Quote 0
          • D
            dangelog 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?)

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

            1 Reply Last reply Reply Quote 0
            • S
              steno 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.

              1 Reply Last reply Reply Quote 0
              • D
                dangelog last edited by

                Then you can use type(). :)

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

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post