1 Attachment(s)
Custom widget in QScrollArea
Hi,
i create a widget in a QScrollArea that should fill the entire widget with red color, but when i scroll to the right, i see that it's not filled completely. The frame is drawn correctly. Here is my code:
Code:
#include <QMainWindow>
#include <QPainter>
#include <QScrollArea>
{
public:
{
painter.fillRect(geometry(), Qt::red);
}
};
{
Q_OBJECT
public:
{
setGeometry
(QRect(100,
100,
230,
230));
MyWidget* widget = new MyWidget;
widget
->setGeometry
(QRect(0,
0,
250,
250));
widget->setStyleSheet("border: 3px solid blue;");
area
->setGeometry
(QRect(0,
0,
200,
200));
area->setWidget(widget);
}
};
This is a simple test dialog. The real widget is an image viewer/editor. I tried QLabel to draw the image, but this is very slow when you zoom in with large images. What i want to do is to zoom and scroll through the image.
What's wrong?
Re: Custom widget in QScrollArea
Have you tried filling (0, 0, width, height)?
Maybe geometry() has negative x/y
Cheers,
_
Re: Custom widget in QScrollArea