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. About paintEvent
QtWS25 Last Chance

About paintEvent

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 4.2k 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.
  • Q Offline
    Q Offline
    qteruk
    wrote on last edited by
    #1

    Hello everyone,

    I add a very simple test paintEvent function to my class MainWindow ( subclass from QMainWindow).

    The problem is that , the function paintEvent hasn't been invoked when I move another window ontop the MainWindow. It is only invoked when the main window is re-sized or change focus to/from another window. But, even the eventPaint function isn't invoked, the content I draw inside the MainWindow::paintEvent still hasn't been erased by the other window that covers it.

    So, does it mean that the window system has stored the content when the window is obscured and then revealed ?
    Can I disable this ?

    Thanks

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

      Why do you want to disable such a feature? And why are you interested in being covered by other windows?

      Redrawing a widget that hasn't changed is just wasting CPU cycles, that's why any modern windowing system will cache toplevel windows contents and never ask them to redraw even if they get obscured.

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

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qteruk
        wrote on last edited by
        #3

        thanks. I just want to see if eventPaint of QWidget will be invoked or not , when the widget is obscured, in this very simple case.

        In another more complicated program, I have a viewer class subclass from QWidget, and draw view content in eventPaint. However, the viewer window is partially erased when another window obscure it. I find that the eventPaint has not been invoked. However, the viewer can redraw normally when I resize the window. Here, I hope the window can redraw after obscured by another window.

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          Why do you want to waste time redrawing if the contents have not changed and the offscreen buffer will suffice?

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

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

            [quote author="qteruk" date="1310312780"]
            So, does it mean that the window system has stored the content when the window is obscured and then revealed ?
            Can I disable this ?[/quote]

            Hi,

            this is the so called double buffering of Qt. Qt has a pixel buffer for each top level widget and each widget draws to this buffer. After all widgets have finished their drawing, the double buffer is blitted to the screen which reduces flickeing and unnessacary repaints which always need calculation (clipping, etc). This feature can be disabled by some widghets attrinbutes, have a look at "QWidget::setAttribute":http://doc.qt.nokia.com/4.7/qwidget.html#setAttribute

            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

            • Login

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