Am 16.08.2012 23:10, schrieb Philipp Menke:
[...] I subclassed QGraphicItem for the various types of Nodes in such a Network (resistors, inductors, capacitors) and for the cables. Having two nodes connected with a cable looks good as long as i leave them on the position they have been that time. The Node-Items are set selectable and movable. When i move a connected one, the cable does not get repainted every time. [...] Every hint/idea is welcome
Ok, as you explicitely welcome _every_ hint, I'll go for mine... ;-)With the backdrop of making your classes less lightweight than a simple QGraphicsItem, you could also inherit your classes from QObject. Then, give the cables a slot redraw() and the nodes a signal moved(). Whenever a cable is connected to a node, call connect(node,SIGNAL(moved()),cable,SLOT(redraw())), whenever a cable is disconnected, call disconnect(...) - note the analogy! ;-)
If you consider QObject too heavy, you might re-implement this behavior by managing a list of connected cables for each node. Although the other direction - the cable stores references to the nodes it connects - would be easier (max. two nodes per cable), it won't help you for your problem.
Best Regards / Mit freundlichen Grüßen Rainer Wiesenfarth -- Tel.: +49 (0)711 22 88-10 * Fax: +49 (0)711 22 88-111 Web: http://www.trimble.com/geospatial/ * http://www.inpho.de/ Trimble Germany GmbH * Branch office Stuttgart Rotebühlstraße 81 * 70178 Stuttgart * Germany Commercial register: HRB 83893, Darmstadt Managing Directors: Dr. Frank Heimberg, Hans-Jürgen Gebauer
smime.p7s
Description: S/MIME Kryptografische Unterschrift
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
