Results 1 to 5 of 5

Thread: QGraphicsPathItem

  1. #1
    Join Date
    Jun 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QGraphicsPathItem

    Hello,

    I'm using a path item to draw a line that connects 2 other items.
    I have a strange selection problem. When I click not far away from the path item, my program says that the item is selected. So I looked around in the net and I found this post:

    http://labs.trolltech.com/blogs/2008...graphicsitems/

    So I tried to define a new bounding region granularity but every this when the granularity is different from 0, my program crashes.
    Here is what my GDB says:

    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0xb6e9e6c0 (LWP 10224)]
    0xb7de7985 in QGraphicsItem::boundingRegionGranularity () from /usr/lib/libQtGui.so.4

    And I don't have an idea why ...
    Do you have any ideas and an example for how to use this setBoundingRegionGranularity().
    In my program I'm using this method in the constructor of the class that is representing the path item (the class is a subclass of the QGraphicsPathItem).

    Thank you in advance.

    Best regards,

    Anton

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGraphicsPathItem

    Hi Anton,

    I don't know the boundingRegion(..) function, but shape() could be the alternative way for what you trying to achieve by using boundingRegion(..).

    Zeck

  3. #3
    Join Date
    Jun 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsPathItem

    Quote Originally Posted by zgulser View Post
    Hi Anton,

    I don't know the boundingRegion(..) function, but shape() could be the alternative way for what you trying to achieve by using boundingRegion(..).

    Zeck
    Yes, I've already tried to implement the shape() method:

    Qt Code:
    1. QPainterPath Wire::shape() const{
    2.  
    3. return path(); //Wire is a sublcass of QGraphicsPathItem
    4. }
    To copy to clipboard, switch view to plain text mode 

    but this gives me the same result.
    I found an example that has a similar visual result of what I would like to make, but there they use only a QPainterPath and not an Item. And in my program I have to use items..
    Here is the example:

    http://doc.trolltech.com/4.4/demos-pathstroke.html

    Anton
    Last edited by tonio; 25th June 2009 at 10:57.

  4. #4
    Join Date
    Jun 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsPathItem

    In fact I'm trying to make lines that are connecting my other items, something like in Visual Studio or similar softs. There the user can drag the lines and adjust them in a way to obtain a more clear scheme ...

    Anton

  5. #5
    Join Date
    Jun 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsPathItem

    I found the solution in some old post.
    For QGraphicsPathItem we should redefine the shape() method using the QPainterPathStroker class and especially the createStroke() method.

    Anton

Similar Threads

  1. QGraphicsPathItem - slow on Mac, fine on X11
    By aeh in forum Qt Programming
    Replies: 0
    Last Post: 18th May 2009, 12:42
  2. Increasing the selection area for a qgraphicsPathitem
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 17th August 2007, 23:03
  3. QGraphicsPathItem Doubt
    By arjunasd in forum Qt Programming
    Replies: 7
    Last Post: 29th July 2007, 03:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.