Results 1 to 14 of 14

Thread: Problem in attachig two polygons

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem in attachig two polygons

    Hi,
    I am doing one application in which, i wrote one class A to create different shapes of polygons. Then i wrote another class B for creating a special polygon which i have to attach with polygons of class A dynamically. Before i did somethinig similar but with QGraphicsItem class using setPos() function for attaching one polygon with another. But with QPolygon, it is working similar. Please suggest me some way.

    Regards
    Rohit

    This is the constructor of class A

    Qt Code:
    1. A::A(DiagramType diagramType, QMenu *contextMenu,
    2. QGraphicsItem *parent, QGraphicsScene *scene)
    3. : QGraphicsPolygonItem(parent, scene)
    4. {
    5. myDiagramType = diagramType;
    6. myContextMenu = contextMenu;
    7.  
    8.  
    9. switch (myDiagramType) {
    10.  
    11. case StartEnd:
    12. path.moveTo(200, 50);
    13. path.arcTo(150, 0, 50, 50, 0, 90);
    14. path.arcTo(50, 0, 50, 50, 90, 90);
    15. path.arcTo(50, 50, 50, 50, 180, 90);
    16. path.arcTo(150, 50, 50, 50, 270, 90);
    17. path.lineTo(200, 25);
    18. myPolygon = path.toFillPolygon(); //myPolygon is an object QPolygonF class
    19. break;
    20.  
    21. case Conditional:
    22. myPolygon << QPointF(-100, 0) << QPointF(0, 100)
    23. << QPointF(100, 0) << QPointF(0, -100)
    24. << QPointF(-100, 0);
    25. break;
    26.  
    27. case Step:
    28. myPolygon << QPointF(-100, -100) << QPointF(100, -100)
    29. << QPointF(100, 100) << QPointF(-100, 100)
    30. << QPointF(-100, -100);
    31.  
    32. break;
    33.  
    34. default:
    35. myPolygon << QPointF(-120, -80) << QPointF(-70, 80)
    36. << QPointF(120, 80) << QPointF(70, -80)
    37. << QPointF(-120, -80);
    38. break;
    39. }
    40.  
    41. anditem = new AndItem();
    42.  
    43. ///// What code to write to attach andItem->myPolygon to myPolygon of this class.////
    44.  
    45.  
    46. setPolygon(myPolygon);
    47. setFlag(QGraphicsItem::ItemIsMovable, true);
    48. setFlag(QGraphicsItem::ItemIsSelectable, true);
    49.  
    50. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 8th May 2007 at 11:59. Reason: missing [code] tags

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.