Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ItemIgnoresTransformations setPos



  • Hi, I have a QGraphicsRectItem with 8 resize handles each with the ItemIgnoresTransformations flag set. I set their pos using setPos relative to their parents rect as follows:

    @
    void CanvasItem::updateHandlePositions()
    {
    double hw = m_handleItems[0]->rect().width()/2;
    double hh = m_handleItems[0]->rect().height()/2;

    for (int i = 0; i < m_handleItems.count(); ++i) {
    case CanvasHandle::TopLeft:
    m_handleItems[i]->setPos(rect().left() - hw,
    rect().top() - hh);
    break;
    case CanvasHandle::Top:
    m_handleItems[i]->setPos(rect().center().x(),
    rect().top() - hw);
    break;
    @

    This sets their positions as shown in a previous post of mine (http://qt-project.org/forums/viewthread/41647/) The problem is that when I scale the view using the following:

    @
    setTransform(QTransform::fromScale(scale, scale));
    @

    the handle is no longer anchored to the corner of the parent rect:

    !http://s30.postimg.org/ga4bmo14t/Screen_Shot_2014_04_24_at_15_42_48.png(handle offset from parent)!

    Can anyone point out what I'm doing wrong?


Log in to reply