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. PaintEvent and class topology...
Forum Updated to NodeBB v4.3 + New Features

PaintEvent and class topology...

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.3k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    ronM71
    wrote on last edited by
    #1

    More and more this seems like a philosophical QT question. I have a widget representing a window A I have a widget representing a window, deriving from A, called B

    B draws its stuff, but I want "A" to contribute some drawing, e.g. draw an image OVER what "B" draws. I want "B" to be completely unaware of this, not having to cooperate with "A" other than deriving from it.

    Is that possible?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      It is possible, but only with some tricks - it's more a C++ problem than Qt, though.

      C++ has the concept of virtual methods, if you reimplement paint() in your subclass B, this method is called, never the method of A. So B has to explicitly call A->paint().

      You can declare a virtual method paintPrivate() in class A. Then reimplement paint() in A and call paintPrivate() there. This will call B's paintPrivate(), you then can do your additional stuff in A's paint(). BUT this will only work as long as you do not reimplement paint() in B. If you do everything is lost again.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ronM71
        wrote on last edited by
        #3

        are paint(), privatePaint() part of QT framework? I am not fully familiar with the entire framework. I'm coming from the "beautiful" world of GDI, Win32 and .NET.... :-)

        1 Reply Last reply
        0
        • R Offline
          R Offline
          ronM71
          wrote on last edited by
          #4

          forget the privatePaint question, i am at the end of a very tiresome week.

          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