Problem with boundingRect() method



  • Hi,

    In a QGraphicsScene instance I want to create a QGraphicsSimpleTextItem (label) as a child item of a
    QGraphicsRectItem (Rectangle). So, I have to set the width and the height of the rectangle (the parent) to the width and the height of the label.

    the boundingRect() of the label class :
    @
    MyLabel::QRectF boundingRect() const
    {
    return QGraphicsSimpleTextItem::boundingRect();
    }
    @

    and in the Rectangle:
    @
    QRectF GraphNode::boundingRect() const
    {
    qreal a = (pen().width())/2;
    return QRectF(-1, -1, label->boundingRect().width()+12, label->boundingRect().height()+12)
    .normalized()
    .adjusted(-a, -a, a, a);
    }
    @

    I created a QTabWidget instance as the central area of the MainWindow. Each tab of the tabwidget contain a GraphicsScene. When I close a tab, the application crash with this error :

    @
    pure virtual method called
    terminate called without an active exception
    Aborted
    @

    The Qt Creator indicate that the problem is in this line:

    @
    return QRectF(-1, -1, label->boundingRect().width()+12, label->boundingRect().height()+12)
    @

    Please, help.

    thanks in advance.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.