Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
This post has been edited 1 times, last edit by "Thomas" (Sep 17th 2004, 10:07am)
Quoted
Originally posted by n_ezdiani
i would like to ask you about the the visiblity of a magnified pixmap...what i mean is, let say the viewport size is smaller than the magnified pixmap, why cant i scroll the rest of the part that havent shown?...
btw i've looked at your jseries tool but I want to try to do it myself ...so could you help me please..
Quoted
Originally posted by Krasu
I think the best way is to use QImage::scale || QImage::smoothScale, anyway, QPixmap can be translated to QImage (see doc.) and back to QPixmap.
Quoted
Originally posted by wysota
Quoted
Originally posted by Krasu
I think the best way is to use QImage::scale || QImage::smoothScale, anyway, QPixmap can be translated to QImage (see doc.) and back to QPixmap.
It's not worth it... the conversions are slow. Better than that is to use QCanvas, QCanvasView, QCanvasSprite and QWMatrix![]()
Quoted
It is very to hard to tell what is wrong without any code. Look at the QjPixmapView. There, the viewport is resized when the zoom factor changes. That is how you do it.
Quoted
Map::Map( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl )
{
.....
ms = new MapScroll(this, "ms");
.....
......
}
MapScroll::MapScroll(QWidget* parent, const char* name)
: QScrollView(parent,"zoom"),bg("images/map.png")
{
bg.load("images/map.png");
setGeometry (20,10,200,260);
setMouseTracking (TRUE);
setDragAutoScroll (TRUE);
setVScrollBarMode( QScrollView::Auto );
setHScrollBarMode( QScrollView::Auto );
};
void MapScroll:: contentsMouseReleaseEvent( QMouseEvent * e)
{
contentsToViewport(e->x(), e->y(),x,y);
qDebug("value x = %d", x);
qDebug("value y = %d", y);
viewport()->update();
}
void MapScroll::drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph)
{
qWarning("inside drawContents");
/* this part is not occurate yet!!*/
if (x<=viewport()->width()/2)
w = 0;
else
w = x - viewport()->width()/2;
if (y<=viewport()->height()/2)
h = 0;
else
h = y - viewport()->height()/2;
/*=========================*/
p->scale(cbono+1,cbono+1);
resizeContents(bg.width()*cbono+1,bg.height()*cbono+1);
p->drawPixmap(0,0,bg,w,h,-1,-1);
}
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
void QjPixmapView::drawContents( QPainter *p, int clipx, int clipy, int clipw, int cliph )
{
p->setBrush( Qt::darkGray );
p->setPen( Qt::darkGray );
p->drawRect( clipx, clipy, clipw, cliph );
if( !pd->pm.isNull() )
{
p->setClipping( false );
int left, top;
if( viewport()->width() <= pd->pm.width()*pd->zoom )
left = 0;
else
left = (int)(viewport()->width()-pd->pm.width()*pd->zoom)/2;
if( viewport()->height() <= pd->pm.height()*pd->zoom )
top = 0;
else
top = (int)(viewport()->height()-pd->pm.height()*pd->zoom)/2;
if( pd->zoom != 1.0 )
{
p->translate( -left*(pd->zoom-1.0), -top*(pd->zoom-1.0) );
p->scale( pd->zoom, pd->zoom );
}
p->drawPixmap( left, top, pd->pm );
if( pd->zoom != 1.0 )
p->resetXForm();
p->setPen( Qt::black );
p->setBrush( Qt::NoBrush );
p->drawRect( left-1, top-1, (int)(pd->pm.width()*pd->zoom+2), (int)(pd->pm.height()*pd->zoom+2) );
}
}
|
Quoted
p->scale(cbono+1,cbono+1);
resizeContents(bg.width()*cbono+1,bg.height()*cbono+1);
p->drawPixmap(0,0,bg,w,h,-1,-1);
center (x,y); // OR ensureVisible(int,int)
This post has been edited 1 times, last edit by "n_ezdiani" (Oct 29th 2004, 4:41am)
Quoted
Originally posted by n_ezdiani
but now, i have a question to ask you regarding the scrollbar...it's like this.... i have a horizontal & vertical scrollbars and besides using the scrollbars, i want to pan the pixmap by clicking on the pixmap... so i tried using center(int,int) or ensureVisible(int,int) so that the clicked point can be centered(visible)... at first, when i click, it can pan the pixmap to the left, right, top or bottom but somehow after a few clicks, the scrollbars keep on increasing to the right and to the bottom respectively eventhough i click to the left or top... seems like after panning to the middle area of the pixmap the pixmap can only be panned to the right and bottom only...it doesnt want to scroll back to the left nor the top...
[/qoute]
This sounds really odd, but it is very hard to tell what has gone wrong from your description.
Quoted
Originally posted by n_ezdiani
btw, is there any other way to make the clicked point visible other than center(int,int) and ensureVisible(int,int)...
[/qoute]
You could always calculate new slider values and setting them manually...
This post has been edited 1 times, last edit by "n_ezdiani" (Nov 1st 2004, 7:18am)