Re: get qgraphicsitem size
How do you change the size of the item ? The size is always mentioned in boundingRect() or shape().
If you are using some variable to change the size, then you must have the size with you. Hope am getting it correct :rolleyes:
Re: get qgraphicsitem size
I am changing it with
if (ui->heightButton->isChecked()==false)
{scene->trackItem->scale(1 ,1.1);}
else
{scene->trackItem->scale(1,.90);}
Re: get qgraphicsitem size
The bounding rect will be same. What happens is the transform of the item is changed, and the item is drawn accordingly.
May be if you tell what you want to achieve, we can tell more clearly.
For now it seems you have a look at transform() function of the QGraphicsItem
Re: get qgraphicsitem size
after i change the size of the item, i want to know the new size
Re: get qgraphicsitem size
Just calculate the new size:
Code:
#include <QtGui>
int main(int argc, char **argv)
{
view.setScene(&scene);
view.show();
qWarning() << item->boundingRect().size() << item->scale() << item->boundingRect().size() * item->scale();
item->setScale(11.91);
qWarning() << item->boundingRect().size() << item->scale() << item->boundingRect().size() * item->scale();
return app.exec();
}
Re: get qgraphicsitem size
I dont think there is a function QGraphicsItem::scale(void) . It simple scales the item but doesnt return anything.
You will need to use QGraphicsItem::transform() and use the matrix variables m11,m22 to multiply with the boundingRect.
Read Basic Matrix Operations
Re: get qgraphicsitem size
Quote:
Originally Posted by
aamer4yu
I dont think there is a function QGraphicsItem::scale(void)
QGraphicsItem::scale()? :cool: (added in 4.6)
Returns
Code:
QSizeF(30, 25) 1 QSizeF(30, 25)
QSizeF(30, 25) 1.91 QSizeF(57.3, 47.75)
Re: get qgraphicsitem size
Thank You for your help
I will try this tonite.
Re: get qgraphicsitem size
aamer4yu
lykurg
Thank You guys !
QGraphicsItem::transform() m11,m22 works !
Re: get qgraphicsitem size
Quote:
QGraphicsItem::scale()? (added in 4.6)
Yeah, u right. Usually at office I have 4.5 assistant open :D