PDA

View Full Version : Zooming..



chethana
9th October 2007, 07:15
Hi all,

Presently i am working in qt4.2.2. As the example given in the Examples and demos i understood the working Image Viewer ...

But my problem is how to zoom the entire screen...

In that example they have used the QLabel... In that they have Loaded iQPixmap ... and then RESIZE and SIZE Functions QLabel they are using...
their they are getting the size of the image and multiplying with scale factor...
How to get the size of entire screen that i want to zoom???

rajesh
9th October 2007, 09:01
chethana,
which widget you are using?
check
width()
and height() function

chethana
10th October 2007, 08:20
I am sending the .bmp image red rectangle portion as i showed in the attachment that portion i want to zoom ... How to get the size ???

chethana
10th October 2007, 08:30
find out the attachment...

rajesh
10th October 2007, 08:37
that area is may be some widget or frame or dialog, right?
what is that? where you drawing these circle?
if you drawing these circle on some widget then you can write two slots:
void myWidget::zoomIn()
{
scale(1.25,1);
update();
}

void myWidget::zoomOut()
{
scale(0.8,1);
update();
}

chethana
10th October 2007, 08:51
HI ,

In a paint event i have written the codefor concentric circle... QMainWindow is my widget...

How to get control over client area... How to zoom the showed region...

rajesh
10th October 2007, 09:09
try this:
void MainWindow::zoomIn()
{
QPainter painter(this);
painter.scale(width() *1.25, height() *1.25);
update();
}
void MainWindow::zoomOut()
{
QPainter painter(this);
painter.scale(width() *0.8, height() *0.8);
update();
}

rajesh
10th October 2007, 09:17
OR
you can implement like this:

void MainWindow::paintEvent(QPaintEvent *event)
{
QPainter painter( this );
painter.drawPixmap( 0,0, m_buffer );
}
void MainWindow::updateWidget()
{
QPixmap tmp( 1200,900 );
tmp.fill(Qt::white);
m_buffer = tmp;
QPainter painter(&m_buffer);
...
painter.setBrush( QColor(120,120,120) );
painter.drawRect(rect);
. . .
}
void MainWindow::zoomIn()
{
QSize size( width() *1.25, height() *1.25);
m_buffer .scaled(size,Qt::KeepAspectRatio, Qt::SmoothTransformation)
update();
}

QPixmap m_buffer ; in .h file