Results 1 to 11 of 11

Thread: Newbie: Circuits and GraphicsView

  1. #1
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Newbie: Circuits and GraphicsView

    Hello,

    Part of a project that I have to do requires that I create a picture of an electric circuit that is editable. As in "circuit", I mean resistors, voltage sources, etc. As in "editable", I mean that I can right click on a component to delete it, insert a new one, edit its value, etc.

    Does anyone know a good way to go about doing this?

    Should I use the GraphicsView Framework to hold the circuit?

    Should I use png or tiff as circuit elements (like resistors and stuff)? Or should I try to draw the parts with Qt?

    I would really, really appreciate any help.

    I'm trying to use the GraphicsView Framework right now. If this is a good route to go and you have any experience using GraphicsView Framework, your help would be much appreciated!

    Thank you!

    From NewbieRY.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Newbie: Circuits and GraphicsView

    I guess you are on the right path for using Graphics View.
    There have been threads related to such electric components in the forum, you can search for them.

    Also have a look at the examples of Graphics View in Qt Demo

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

    RY (19th September 2008)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie: Circuits and GraphicsView

    Yes, use GraphicsView. As for items themselves, it depends on you - you can use pixmaps but you can also draw those items yourself which would give you more flexibility (for example ability to change the colour of the item).

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

    RY (19th September 2008)

  6. #4
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: Newbie: Circuits and GraphicsView

    Thanks for the speedy reply!

    Would you happen to know if there any walkthroughs or comments for the demos of QGraphicsView? Because it's a little difficult to piece together how everything works with straight code.

  7. #5
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: Newbie: Circuits and GraphicsView

    Thanks again for your speedy reply!

    If I do draw the items with functions in Qt, would that be using the QPainter class or is there something else?

    If it's not too much trouble, could you possible post some example code?

  8. #6
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Newbie: Circuits and GraphicsView


  9. The following user says thank you to GuL for this useful post:

    RY (19th September 2008)

  10. #7
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: Newbie: Circuits and GraphicsView

    Thanks for your speedy reply!

    I'm looking for a more basic example though. Like really basic that only shows you what is absolutely necessary. A lot of the examples are great, but they seem to cram too many concepts into one, so it's difficult to know what is affecting where without comments.

  11. #8
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Newbie: Circuits and GraphicsView

    Didnt you go through Qt Demos ? There are good examples there..
    You can start with Colliding mice or Diagram scene examples

  12. The following user says thank you to aamer4yu for this useful post:

    RY (19th September 2008)

  13. #9
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Newbie: Circuits and GraphicsView

    For creating a custom QGraphicsItem, what is the bounding rectangle doing? For example in the Colliding Mice Example, why do you need the "adjust" and how do the numbers in QRectF reflect the mouse?

    Thank you!

  14. #10
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Newbie: Circuits and GraphicsView

    why do you need the "adjust"
    I guess that is to account for pen width. When drawing a line, some more pixels will be occupied in drawing. Hence to account the bounding rect properly, adjust is included. In cases where where pen width is more than one, u will need to modify adjust accordingly.

    how do the numbers in QRectF reflect the mouse?
    They dont reflect the mouse. They reflect the rectangle that is occupied by the mouse. ie. smallest rectangle in which the mouse will fit in.

    Also you might ask what does the rect in shape do ? shape is used in case of collision detection. So when mouse rect in the shape function gets collided, it show collision detection..

  15. The following user says thank you to aamer4yu for this useful post:

    RY (19th September 2008)

  16. #11
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Newbie: Circuits and GraphicsView

    Would anyone know if it's possible to create a widget that contains both the QGraphicsView and its scene that is viewable in Main Window?

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.