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. How to implement boundingRect and shape methods for a custom QGraphicLineItem item
Forum Updated to NodeBB v4.3 + New Features

How to implement boundingRect and shape methods for a custom QGraphicLineItem item

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 672 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.
  • J Offline
    J Offline
    jeevan_reddy
    wrote on last edited by
    #1

    Hi All,
    How to implement boundingRect and shape methods for a custom qgraphicline item, so that the item is easily selected when mouse is clicked on the item end points? Currently the custom line item is not receiving the mouse press events consistently. The mouse press is happening only randomly. I need to click on the line end points inorder to rotate and resize the line item.

    Please find my cureent implementation

    @
    QRectF CustomGraphicsLineItem::boundingRect()
    {
    return QGraphicsLineItem::boundingRect();
    }
    QPainterPath CustomGraphicsLineItem::shape()
    {
    //return QGraphicsLineItem::shape();
    const int adjustment = 5;
    QPainterPath path;
    QRectF rect = boundingRect();
    path.addRect(rect.adjusted(-adjustment, -adjustment, adjustment, adjustment));
    return path;

    }
    @

    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