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. Disable widget background fills before paint
Forum Updated to NodeBB v4.3 + New Features

Disable widget background fills before paint

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 5.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.
  • N Offline
    N Offline
    neurocod
    wrote on last edited by
    #1

    Initial problem is flickering:
    after widget resized (enlarged), exposed background is filled with some color and than control goes to custom paint function. If custom paint is slow (insert sleep(200)), there is visible transition, especially for exposed regions. I searched for solution to disable initial background fills, so delay before custom paint if invisible. The only solution that worked was setWindowFlags(Qt::FramelessWindowHint), but this is inappropriate.
    Code to reproduce:

    @#include <QtGui>
    #include <QTest>

    class TestScene: public QGraphicsScene {
    public:
    virtual void drawBackground(QPainter * painter, const QRectF & rect) {
    QTest::qSleep(200);
    painter->fillRect(rect, Qt::blue);
    }
    };

    int main(int argc, char *argv[]) {
    QApplication a(argc, argv);
    QGraphicsView w;
    w.setScene(new TestScene());
    w.show();
    return a.exec();
    }
    //try to enlarge widget by mouse, see flickering with different color
    @
    I tried to disable background fills with many other ways, such as:
    @ setAttribute(Qt::WA_TranslucentBackground);
    setAttribute(Qt::WA_OpaquePaintEvent);
    setAttribute(Qt::WA_NoSystemBackground);
    setAutoFillBackground(false);@
    but debug showed that QWidgetPrivate::paintBackground is called anyway (from /src/gui/kernel/qwidget.cpp QWidgetPrivate::drawWidget).
    I changed QWidgetPrivate::paintBackground so it didn't do anything. Situation became better - some artifacts became on screen, but that flickering remained. Even if no custom paint (leave only delay without printing commands), there was flickering with different colors on resize. Where can I found code which makes such fills, so I can change it? Thanks.
    PS WIndows 7 64 bit, Qt 4.7.4-32

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

      Perhaps, the problem you are facing is an OS problem.
      If you resize a window, windows reserves the painting area. Qt itself works with double buffering, so the buffer is blit to to the screen, when all painting is done.

      If you trigger some repaint by your selfe, this could be a reason, but otherwise, it should not be.

      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
      • N Offline
        N Offline
        neurocod
        wrote on last edited by
        #3

        You are right - I tested under Windows XP and there is no flickering. Thanks.

        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