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

GraphicsItem's area that can be selected keep size



  • Hi,bro
    The area that can be selected keep size ,don't change with boundingRect() 's changed

    when geometry change i do this:

    prepareGeometryChange();    
    rectBound.setTopLeft( topLeft );  
    rectBound.setWidth( newWidth);  
    rectBound.setHeight(newHeight);
    

    I'm not good at English and I don't know if I can express myself clearly.
    Hope to get helps;
    thx



  • QRectF  ModuleItem::boundingRect() const
    {
       return rectBound;
    }
    
    void  ModuleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
    {
    //.....
     painter->drawPixmap( rectBound,scaled,  QRectF(0,0,width,height));
    }
    

  • Lifetime Qt Champion

    Hi,

    Sorry but it's not really clear. You might want to post images that shows your issue.



  • @markwang said in GraphicsItem's area that can be selected keep size:

    if I can express myself clearly

    The boundingRect does NOT change, but you want to change
    OR
    it changed, but you want to have it fixed?

    EDIT:

    The area that can be selected keep size ,don't change with boundingRect() 's changed

    Your pixmap doesn't change when you change the boundingRect?


Log in to reply