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

Qt-interest Archive, December 2000
Problems to update or redraw a QScrollView-class


Message 1 in thread

Hi,

I'm experiencing some trouble using the QScrollView-class.  I have
created a class by inheriting from QScrollView and overwrite the
function drawContents(..) to show an image. The scale-function is used
to change virtually the size of the picture.

void ImageView::drawContents(QPainter * p, int clipx, int clipy, int
clipw, int cliph)
{
    ...
    p->scale(m_zoom, m_zoom);
    ...
    p->drawImage(0, 0, *m_pimage);
    ...
}

void ImageView::SetZoom(double zoom)
{
     m_zoom = zoom;

    int width, height;
    width = ((int) ((double) m_width * m_zoom)) + 1;
    height = ((int) ((double) m_height * m_zoom)) + 1;

    resizeContents(width, height); // set size of scrolling-area

    update() // It doesn't work. (The same behavior with repaint() and
erase().)
}

Everything looks fine. But if I want to change the zoom only a part of
the client area is updated. The image isn't complete painted and several
pieces with several factors of zoom are visible. I've tried update(),
repaint() and erase(). Nothing works.

Does anybody know what I'm doing wrong?

Thanks in advance
Raul




Message 2 in thread


Thanks ! That's the solution.

Raul


> Hi !
>
> Did you use scrollview->viewport()->update(); you should update the viewport
> not the scrollview widget itself.
>
> Mikael
>
> ----- Original Message -----
> From: "Raul Rosenlvcher" <rosenl@iet.et.tu-dresden.de>
> To: "QT Mailingliste" <qt-interest@trolltech.com>
> Sent: Friday, December 08, 2000 3:09 PM
> Subject: Problems to update or redraw a QScrollView-class
>
> > Hi,
> >
> > I'm experiencing some trouble using the QScrollView-class.  I have
> > created a class by inheriting from QScrollView and overwrite the
> > function drawContents(..) to show an image. The scale-function is used
> > to change virtually the size of the picture.
> >
> > void ImageView::drawContents(QPainter * p, int clipx, int clipy, int
> > clipw, int cliph)
> > {
> >     ...
> >     p->scale(m_zoom, m_zoom);
> >     ...
> >     p->drawImage(0, 0, *m_pimage);
> >     ...
> > }
> >
> > void ImageView::SetZoom(double zoom)
> > {
> >      m_zoom = zoom;
> >
> >     int width, height;
> >     width = ((int) ((double) m_width * m_zoom)) + 1;
> >     height = ((int) ((double) m_height * m_zoom)) + 1;
> >
> >     resizeContents(width, height); // set size of scrolling-area
> >
> >     update() // It doesn't work. (The same behavior with repaint() and
> > erase().)
> > }
> >
> > Everything looks fine. But if I want to change the zoom only a part of
> > the client area is updated. The image isn't complete painted and several
> > pieces with several factors of zoom are visible. I've tried update(),
> > repaint() and erase(). Nothing works.
> >
> > Does anybody know what I'm doing wrong?
> >
> > Thanks in advance
> > Raul
> >
> > --
> > List archive and information: http://qt-interest.trolltech.com/