Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Scale problem with scroll bar in QGraphicsProxyWidget
Forum Updated to NodeBB v4.3 + New Features

Scale problem with scroll bar in QGraphicsProxyWidget

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    krlei
    wrote on last edited by
    #1

    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));

    }
    @

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pal_vic
      wrote on last edited by
      #2

      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;
      }
      }@

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved