Results 1 to 6 of 6

Thread: Drawing rectangles in QT

  1. #1
    Join Date
    Aug 2010
    Posts
    14
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Drawing rectangles in QT

    I would like to draw squares and withing them, small circles that can be connected to other squares in other squares by a polyline or so.

    I would like to know how to do that in QT.

    Attached an image for more illustration.image
    test.png

  2. #2
    Join Date
    Jan 2012
    Posts
    66
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Platforms
    Windows

    Default Re: Drawing rectangles in QT

    Use a QGraphicsScene/View, then subclass QGraphicsItem to make the squares with circles. Do you want the user to be able to connect notes by dragging, or do you want to connect them yourself programmatically?

  3. #3
    Join Date
    Aug 2010
    Posts
    14
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: Drawing rectangles in QT

    Thanks.
    Yea, I would like the user to connect the nodes by dragging.

  4. #4
    Join Date
    Jan 2012
    Posts
    66
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Platforms
    Windows

    Default Re: Drawing rectangles in QT

    Then you should reimplement some protected functions in your QGraphicsItems, particularly mousePressEvent, mouseMoveEvent, and mouseReleaseEvent. mousePressEvent would notify the item to draw a line (probably another QGraphicsItem), from the initial click location to mouseMoveEvent's current location. mouseReleaseEvent could call scene().itemAt() to determine which node is at the mouse release location. Something like that.

  5. The following user says thank you to wayfaerer for this useful post:

    andreahmed (26th February 2012)

  6. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Drawing rectangles in QT

    The Diagram Scene Example would be a good starting place

  7. The following user says thank you to ChrisW67 for this useful post:

    andreahmed (26th February 2012)

  8. #6
    Join Date
    Aug 2010
    Posts
    14
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: Drawing rectangles in QT

    How to draw circles around triangles? and those circles can be connected to other circles ?!

Similar Threads

  1. Replies: 1
    Last Post: 19th April 2011, 11:17
  2. Replies: 0
    Last Post: 14th November 2010, 13:36
  3. Replies: 1
    Last Post: 9th August 2010, 19:44
  4. editable rectangles
    By parmar ranjit in forum Qt Programming
    Replies: 3
    Last Post: 20th February 2008, 09:59
  5. Replies: 4
    Last Post: 17th January 2006, 17:46

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.