QScrollArea - Painting happens in background , not in correct widget
Hi,
i trying to Port a GUI from QT3 to QT4.
The Scrolling in my Widget was implemented using QScrollview.
The painting works correct, but the Pixmap is painted in the background (not the correct widget) in full size and there are no scrollbars.
I think, that the setting of the widget is not happening correct..
The painting is done on viewport()..
Here's the piece of code I think the problem lies:
Code:
...
widget->setLayout(layout);
setWidget(widget);
...
}
Thx in advance
--
bensh
Re: QScrollArea - Painting happens in background , not in correct widget
i suppose you are using the paintevent of your XXX::XXX class?
Re: QScrollArea - Painting happens in background , not in correct widget
Re: QScrollArea - Painting happens in background , not in correct widget
Where and how are you painting the pixmap ?
Re: QScrollArea - Painting happens in background , not in correct widget
Thanks for the fast reply..
First in RefreshPixmap the pixmap is created (this works fine.. because it's painted correct, but in the wrong widget)
Then I'm calling from PaintEvent a draw-function where the pixmap is painted onto the widget (viewport()).
Somewhere below has to be the problem, but I already tried everything :((
Code:
if (m_Pixmap.isNull()) refreshPixmap();
draw(event->rect().x(), event->rect().y(), event->rect().width(), event->rect().height(),&p);
}
void xxx
::draw(int cx,
int cy,
int cw,
int ch,
QPainter* p
) { p->begin(viewport());
p->drawPixmap(0, 0, m_Pixmap);
p
->drawPixmap
(QRectF(cx
- this
->geometry
().
x(), cy
- this
->geometry
().
y(), cw, ch
), m_Pixmap,
QRectF(cx
- this
->geometry
().
x(), cy
- this
->geometry
().
y(), cw, ch
));
}
Re: QScrollArea - Painting happens in background , not in correct widget