Results 1 to 2 of 2

Thread: QRegion multiply

  1. #1
    Join Date
    Jul 2006
    Posts
    126
    Thanks
    17
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QRegion multiply

    Hi,

    I'm doing a map creator for a isometric game and I use a zoom (qreal) for scale the QPainter surface for zoom, also I use a QRegion (polygon not rectangle) and need to multiply the area for know the square that is below the cursor. How can I do it?

    Thank's bye.

    Sample code
    Qt Code:
    1. Square *square=map.getSquare(i,j);
    2. QRegion region(square->region());
    3. if(square->region().contains(cursorPos)){
    4. //if(region.contains(cursorPos)){
    5. painter.setPen(Qt::red);
    6. selectedSquarePosX=i; selectedSquarePosY=j;
    7. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jul 2006
    Posts
    126
    Thanks
    17
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QRegion multiply

    Hehehe I have a valid solution:

    Qt Code:
    1. Square *square=map.getSquare(i,j);
    2. QPolygon zoomedPoly;
    3. zoomedPoly<<square->left()*zoom
    4. <<square->up()*zoom
    5. <<square->right()*zoom
    6. <<square->down()*zoom;
    7. QRegion region(zoomedPoly);
    8. if(region.contains(cursorPos)){
    9. painter.setPen(Qt::red);
    10. selectedSquarePosX=i; selectedSquarePosY=j;
    11. }
    To copy to clipboard, switch view to plain text mode 

    Square inherits from QPolygon and has defined up(), right(), down(), left() as points of the polygon.

    Anyway is there a better solution for it?

Similar Threads

  1. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 19:42

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.