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. [Solved] drawing sympols
Forum Updated to NodeBB v4.3 + New Features

[Solved] drawing sympols

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.4k 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.
  • M Offline
    M Offline
    miniCircuit
    wrote on last edited by
    #1

    hello all;

    this is what i want to do:

    1. drawing a circle/polygon with a letter inside my circle/polygon
    2. drawing a line between my symbols
    3. i want to label my circle with a number, the label gonna be drawn on top of my circle/polygon
    4. i want to be able to drag/drop my symbols

    so what do you think is the best way of implementing it with qtcreator? shall i use QGraphicsObject or QPaint directly ?

    1 Reply Last reply
    0
    • I Offline
      I Offline
      issam
      wrote on last edited by
      #2

      Hi,
      I think you have to use QGraphicsScene !
      So, subclass QGraphicsScene to implement the drag/drop protected functions. You can also go to the Qt examples in your Qt installation directory and study the diagramScene example.

      In the other hand, to draw custom circles and polygons items, you have to subclass QGraphicsEllipseItem and QGraphicsPolygonItem and to reimplement those methods:
      @
      virtual QRectF boundingRect() const;
      virtual QPainterPath shape () const;
      virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget );
      @

      drawing label inside or in top of an item is easy. You can use QGraphicsSimpleTextItem :
      @
      MyCircleItem::MyCircleItem () : QGraphicsEllipseItem()
      {
      setRect(0, 0, 100, 100);

      label = new QGraphicsSimpleTextItem(this);
      label->setPos(20, 20);
      }
      @

      This will draw the label as a QGraphicsSimpleTextItem inside the Circle Item when the paint() method is called :)

      http://www.iissam.com/

      1 Reply Last reply
      0
      • M Offline
        M Offline
        miniCircuit
        wrote on last edited by
        #3

        you are awesome :D
        thank you so much issam thats what i really need;

        1 Reply Last reply
        0
        • I Offline
          I Offline
          issam
          wrote on last edited by
          #4

          good :)
          Try to find a way to add a [Solved] tag to the title :)

          http://www.iissam.com/

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mlong
            wrote on last edited by
            #5

            bq. Try to find a way to add a [Solved] tag to the title :)

            For the record, you can do that by editing your initial post and modifying the thread title.

            Software Engineer
            My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

            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