Results 1 to 4 of 4

Thread: any idea for doing this project by Qt

  1. #1
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Windows Android

    Default any idea for doing this project by Qt

    hi, there are 5 points. some of these points have connection with anothers. for example point A is connected to Point E and point E is connected to point D. point B is connected to point C. I attached the picthere of these connections below. is under two things posiable by Qt?
    1- drawing points in different color like the uploaded picture?
    2- conncting these points together by a line easily by clicking on point?

    thanks
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,022
    Thanks
    233
    Thanked 641 Times in 631 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: any idea for doing this project by Qt

    Of course, anything is possible with Qt

    I would use the Qt Graphics / View architecture for this. QGraphicsEllipseItem can be used for the circles, QGraphicsSimpleTextItem or QGraphicsTextItem for the labels, and QGraphicsPathItem and a QPainterPath for the lines.

    If you want to be able to move the points around and have the endpoints of the lines follow the points, you'll need to add code for that. A good example is the Elastic Nodes demo project in the Qt distro. The Drag and Drop Robot example and the Diagram Scene example show how to interact with graphics items in a scene through a graphics view.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    QJak (8th March 2019)

  4. #3
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    363
    Thanks
    87
    Thanked 12 Times in 12 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: any idea for doing this project by Qt

    Alternatively, you could also familiar yourself with the QPainter object and use it's drawEllipse() and drawLine() methods to implement the drawing of the dots and the lines in the paintEvent() of a QWidget, and use the mouseMoveEvent() and mousePressedEvent() handlers to implement your own logic. The QGraphicsView environment does make things easier in the long run as it automatically takes care of things for you like routing mouse clicks happening on the dots into certain functions, but it also requires a steep learning curve on top of understanding how QWidgets, events, and painting work which might scare off a Qt beginner, as I believe the OP is. Using a raw QWidget + QPainter environment is much easier to get you started, imho.

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

    QJak (15th March 2019)

  6. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,022
    Thanks
    233
    Thanked 641 Times in 631 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: any idea for doing this project by Qt

    I agree in part, if all you need are static images on screen. But I personally think it is much harder to get interaction with graphics on screen to work when you have to implement all that code yourself. Being able to create a QGraphicsItem with properties that allow it to be movable, and then just being able to click on it and move it (with all of that logic being handled by the G/V framework) is much easier than having to invent that wheel yourself. Likewise, being able to derive a complex QGraphicsItem and implement the drawing in its own coordinate system, knowing that the G/V framework can do things like make copies, scale, rotate, and translate it without any changes to your code is a big plus. And being able to create a QGraphicsScene once and display different viewports on it in different windows with no code changes to the scene is fantastic.

    I've done complex scientific graphics both ways. For me, the G/V framework will be the way to go for future needs.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    QJak (15th March 2019)

Similar Threads

  1. Do I get the idea of QAudioProbe?
    By Khaine in forum Newbie
    Replies: 1
    Last Post: 11th September 2015, 22:12
  2. Project interface idea
    By robel in forum Newbie
    Replies: 7
    Last Post: 10th September 2015, 08:29
  3. ???any one have idea about this ???
    By damodharan in forum Qt Programming
    Replies: 1
    Last Post: 29th May 2010, 09:08
  4. No idea about QGraphicsView
    By Shawn in forum Qt Programming
    Replies: 2
    Last Post: 27th June 2007, 10:02
  5. UI Idea please
    By munna in forum General Discussion
    Replies: 1
    Last Post: 9th May 2006, 11:14

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.