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. Problem with boundingRect() method

Problem with boundingRect() method

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.2k Views
  • 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.
  • I Offline
    I Offline
    issam
    wrote on 23 Jun 2013, 23:47 last edited by
    #1

    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.

    http://www.iissam.com/

    1 Reply Last reply
    0

    1/1

    23 Jun 2013, 23:47

    • Login

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