[Qt-interest] Fit the Geometry on the screen

Sujan Dasmahapatra sdh at lmglasfiber.com
Tue Jun 23 09:58:50 CEST 2009


////////////////////////////////////////////////////////////////////////
/////////////////////////////////
QGraphicsView *view = new QGraphicsView;
QGraphicsItem *geometry = new QGraphicsItem;
if(translateRadioButton->isChecked()==true) {
QString dxString = dxLineEdit->text();
QString dyString = dyLineEdit->text();
double dx  = dxString.toDouble();       // for translation
double dy  = dyString.toDouble();
geometry->translate(dx,dy);
}
else if(rotationRadioButton->isChecked()==true) {
QString angleString = angleLineEdit->text();
QString xcString = xcLineEdit->text();
QString ycString = ycLineEdit->text();           // for rotation
double angle  = angleString.toDouble();
double xc  = xcString.toDouble();
double yc  = ycString.toDouble();
geometry->setTransform(QTransform().translate(xc,
yc).rotate(angle).translate(-xc, -yc));
} 
else if(scalingRadioButton->isChecked()==true) {
QString factorString = factorLineEdit->text();
double factor  = factorString.toDouble();              // for scaling
geometry->scale(factor,factor);
}
else
statusBar()->showMessage(tr("No transformation"),2000)

//slot for fitting the graphicsItem on the screen.
fitInviewFunction()
{
	View->fitInView(geometry,Qt::KeepAspectRatio);
}
////////////////////////////////////////////////////////////////////////
//////////////////////////////////
////////////////////////////////////////////////////////////////////////
//////////////////////////////////
Please check the rotation and scaling part if its correct and also
fitInView() part....

Kind Regards,
Sujan Dasmahapatra

-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Sean Harmer
Sent: Tuesday, June 23, 2009 1:10 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Fit the Geometry on the screen

On Tuesday 23 Jun 2009 08:36:28 Sujan Dasmahapatra wrote:
> Sean I am performing translation,rotation and scaling on the
> graphicsitem, so for some high value in translation the graphicsitem
> moves out of screen.how can I get it back to to screen and fit on the
> view properly.??
That's nice. Example code that show the problem please? You never know,
in 
putting the example together you might find the solution yourself.

Sean

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list