Results 1 to 4 of 4

Thread: How to rotate a lattice of hexagons in Qt

  1. #1
    Join Date
    Jan 2012
    Posts
    66
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Platforms
    Windows

    Default How to rotate a lattice of hexagons in Qt

    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...nterpaths.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!

    Anthony

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

    Default Re: How to rotate a lattice of hexagons in Qt

    Graphics View seems the obvious choice.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    wayfaerer (7th February 2012)

  4. #3
    Join Date
    Jan 2012
    Posts
    66
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Platforms
    Windows

    Default Re: How to rotate a lattice of hexagons in Qt

    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?

  5. #4
    Join Date
    Jan 2012
    Posts
    66
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Platforms
    Windows

    Default Re: How to rotate a lattice of hexagons in Qt

    To anyone interested, just re-implement QGraphicsItem::Shape.

Similar Threads

  1. rotate in QState
    By estel in forum Qt Programming
    Replies: 0
    Last Post: 21st October 2009, 12:39
  2. Rotate a QRectF
    By whitefurrows in forum Qt Programming
    Replies: 5
    Last Post: 15th July 2009, 15:33
  3. Rotate QLabel
    By Qt Coder in forum Newbie
    Replies: 2
    Last Post: 19th March 2009, 11:25
  4. how to rotate an image...
    By sh123 in forum Qt Programming
    Replies: 2
    Last Post: 15th January 2009, 14:59
  5. QGraphicsRectItem::rotate()
    By LestorN in forum Qt Programming
    Replies: 1
    Last Post: 20th October 2006, 10:17

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.