View Full Version : How to rotate a lattice of hexagons in Qt

12th January 2012, 18:20
Hi, I want to create a lattice of hexagons in Qt that the user can rotate via a slider specifying the angle. How can this be achieved as efficiently as possible in Qt?

The painter paths example (http://developer.qt.nokia.com/doc/qt-4.8/painting-painterpaths.html) looks promising, but I'm not sure if it's the way to go given that there will be hundreds of hexagons, all rotating around each other (i.e., the lattice will be rotating).

I'd appreciate any advice. Thanks!


12th January 2012, 18:59
Graphics View seems the obvious choice.

28th January 2012, 06:02
Thanks, Graphics View has been working out well. However, I have encountered a bit of a problem, which is that I can't get the correct hexagon from a mouse click due to the fact that the bounding rectangles of adjacent hexagons overlap. I'm currently using a subclassed QGraphicsItem. Would I need to re-implement a method in QGraphicsItem? Or perhaps QGraphicsView or QGraphicsScene?

28th January 2012, 08:19
To anyone interested, just re-implement QGraphicsItem::Shape.