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

Qt-interest Archive, October 2007
repaint() and paintEvent() call problem


Message 1 in thread

Hi! I am trying to learn Qt and already have a question. I looked into api for
void QWidget::repaint() and it says quote:

"Repaints the widget directly by calling paintEvent() immediately, unless updates
 are disabled or the widget is hidden."

But i looked into qwidget.cpp's (qt4.2.3) source code and there are 3 different
definitions which are like below:

void QWidget::repaint()
{
    Q_D(QWidget);
    repaint(d->clipRect());
}

void QWidget::repaint(int x, int y, int w, int h)
{
    if (x> data->crect.width() || y> data->crect.height())
        return;

    Q_D(QWidget);
    if (w < 0)
        w = data->crect.width()  - x;
    if (h < 0)
        h = data->crect.height() - y;
    repaint(d->clipRect().intersected(QRect(x, y, w, h)));
}

void QWidget::repaint(const QRect &r)
{
    Q_D(QWidget);
    repaint(QRegion(d->clipRect().intersected(r)));
}

The problem is none of them call paintEvent() function. so how does paintEvent()
get called? Also if you look above at the first definition of repaint() it calls
repaint(d->clipRect()) so the candidate for this function call is:

void QWidget::repaint(const QRect &r)

which in turn calls

repaint(QRegion(d->clipRect().intersected(r)));

its prototype is:

void QWidget::repaint(QRegion&);

I cannot find the defintion of such function. does it exist? If no how does repaint()
perform its task with an incomplete definition? Is there any other explanation for
this that i'm not aware of? Thanks.





_________________________________________________________________
Have fun while connecting on Messenger! Click here to learn more.
http://entertainment.sympatico.msn.ca/WindowsLiveMessenger
--
 [ signature omitted ] 

Message 2 in thread

Hey,

> Hi! I am trying to learn Qt and already have a question. I looked into api for
> void QWidget::repaint() and it says quote:
> 
> "Repaints the widget directly by calling paintEvent() immediately, unless updates
>  are disabled or the widget is hidden."
> 
> But i looked into qwidget.cpp's (qt4.2.3) source code and there are 3 different
> definitions which are like below:
> 

I do not know the details, but I am sure you have to follow the leads in
qbackingstore.cpp. See: void QWidget::repaint(const QRegion& rgn)

Greetings

Niklas

--
 [ signature omitted ] 

Message 3 in thread

>>Hofmann wrote:
>>Hey,
>
>DC wrote:
> Hi! I am trying to learn Qt and already have a question. I looked into api for
> void QWidget::repaint() and it says quote:
> 
> "Repaints the widget directly by calling paintEvent() immediately, unless updates
>  are disabled or the widget is hidden."
> 
> But i looked into qwidget.cpp's (qt4.2.3) source code and there are 3 different
> definitions which are like below:
> 
> 
>>I do not know the details, but I am sure you have to follow the leads in
>>qbackingstore.cpp. See: void QWidget::repaint(const QRegion& rgn)

Filename where that function is defined is different from that of where its prototype is
declared. I never thought you could do that.  Thanks for pointing that out.

_________________________________________________________________
R U Ready for Windows Live Messenger Beta 8.5? Try it today!
http://entertainment.sympatico.msn.ca/WindowsLiveMessenger
--
 [ signature omitted ] 

Message 4 in thread

A D schrieb:
> Filename where that function is defined is different from that of where its prototype is
> declared. I never thought you could do that.  Thanks for pointing that out.

C++ is not Java :)

--
 [ signature omitted ] 

Message 5 in thread

Hi,

> The problem is none of them call paintEvent() function. so how does paintEvent()
> get called? Also if you look above at the first definition of repaint() it calls
> repaint(d->clipRect()) so the candidate for this function call is:
> 
> void QWidget::repaint(const QRect &r)
> 
> which in turn calls
> 
> repaint(QRegion(d->clipRect().intersected(r)));
> 
> its prototype is:
> 
> void QWidget::repaint(QRegion&);
> 
> I cannot find the defintion of such function. does it exist? If no how does repaint()
> perform its task with an incomplete definition? Is there any other explanation for
> this that i'm not aware of? Thanks.

This depends on the platform your application is running on.

On the Mac the actual paint event is sent after we receive 
kEventControlDraw from Carbon (qwidget_mac.cpp). On the other platforms 
the actual paint event is sent from QWidgetPrivate::drawWidget 
(qbackingstore.cpp).

Hope this was helpful.

-- 
 [ signature omitted ]