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.
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
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).
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.
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?
Re: Newbie: Circuits and GraphicsView
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.
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
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!
Re: Newbie: Circuits and GraphicsView
Quote:
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.
Quote:
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..
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?