I'm a Qt beginner.
So I have my MainWindow with a QSlider
and a QPixmap
. I redefined the paintEvent( QPaintEvent* event )
and
connect( slider, SIGNAL(valueChanged(int)), this, SLOT(centerChange(int)) );
with a slot:
void MainWindow::centerChange(int value)
{
center = value;
update();
}
So I wanted repainte the Pixmap only if the slider's value is changed. But I notice that everytime when I make a mouse-in or a mouse-out to the slider, the repaint is triggered. Why is this happenning?
Thanks.
Paint event may be triggered at any time by the underlying Qt drawing system. You should not assume that paint event can be triggered only by you. You need to change the logic in your app.