Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, June 2007
Drawing debug rectangles


Message 1 in thread

Does anyone know how to achieve this under Linux.

 

I want to flash a brief red rectangle where the redraw is about to
happen and then have it paint as normal.

 

I tried the following code with no luck

 

void MyClass::paintEvent(QPaintEvent * e)

{

            QRect r = e->rect();

            usleep(500);

            QPainter p(this);

            p.fillRect(r,Qt::red);

            QCoreApplication::flush();

            usleep(800);

            

            // regular drawing code

}


Message 2 in thread

Try running your app with the environment variable "QT_FLUSH_PAINT" set to
1. For example:
$ QT_FLUSH_PAINT=1 ./myapp
This will make each rectangle flash yellow before drawing as usual.

Tom

On 6/22/07, Jonathan Neitz <JonathanNeitz@xxxxxxxxxxxxx> wrote:
>
>  Does anyone know how to achieve this under Linux.
>
>
>
> I want to flash a brief red rectangle where the redraw is about to happen
> and then have it paint as normal.
>
>
>
> I tried the following code with no luck
>
>
>
> void MyClass::paintEvent(QPaintEvent * e)
>
> {
>
>             QRect r = e->rect();
>
>             usleep(500);
>
>             QPainter p(this);
>
>             p.fillRect(r,Qt::red);
>
>             QCoreApplication::flush();
>
>             usleep(800);
>
>
>
>             // regular drawing code
>
> }
>