Scale problem with scroll bar in QGraphicsProxyWidget
-
Hi everyone,
I created my own class by subclassing QGraphicsProxyWidget in a way that it ignores parent item transformation and that it resizes
itself in private member slot function ResizeWidget() which is called every time when parent emits signal scaleChanged(). Function ResizeWidget() accepts scale value from parent and resizes widget by multiplying initial widget's width and height with scale value. I used this customized QGraphicsProxyWidget class for showing QTextWidget in QGraphicsScene and other widgets that have scroll bar.
Problem occurs after resizing widget when I hover with mouse over scroll bar area it trembles for several pixels.Can anyone help me to resolve this behavior?
Code looks like below:
@GraphicsProxyWidget::GraphicsProxyWidget(QGraphicsItem *parent) :
QGraphicsProxyWidget(parent)
{
connect(this->parentObject(),
SIGNAL(scaleChanged ()),
this,
SLOT(ResizeWidget ()));this->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setFocusPolicy(Qt::StrongFocus);m_number_of_zoom = 0;
}void GraphicsProxyWidget::ResizeWidget()
{
qreal scale = this->parentObject()->scale();m_number_of_zoom ++;
if(m_number_of_zoom == 1)
{
m_height = this->geometry().size().height();
m_width = this->geometry().size().width();
m_x_coor = this->pos().x();
m_y_coor = this->pos().y();}
this->resize(m_widthscale, m_heightscale);
//this->setGeometry(QRectF(m_x_coor, m_y_coor, m_widthscale, m_heightscale));}
@ -
Hi.
To round the width and height of int type.
I wrote code like this:
QML:
@ Rectangle {
width: (parent.width / 2)-(parent.width / 2)%2;
....
ScrollAreaWithGraphicsProxyWidget {
anchors.fill: parent;
}
}@