Results 1 to 20 of 21

Thread: Probem Tiling an image with QPixmap

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Probem Tiling an image with QPixmap

    Ok, leave it commented out, so that we can easily find the problem.
    In the screenshot you posted, there are 4 pixmaps - you get all 4 even with only one for loop in your paintEvent()?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. #2
    Join Date
    Dec 2010
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Probem Tiling an image with QPixmap


    Thats what I talked about in the last post.If you look at the "collisionimages" you'll see that they're also on the wrong position.

    EDIT:
    Yeah I get 4 images if I leave it commented.The result is the same.

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Probem Tiling an image with QPixmap

    I am sorry, how your answer is answering my question?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Dec 2010
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Probem Tiling an image with QPixmap

    Sorry.
    The result is the same as shown above in the image I posted.

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Probem Tiling an image with QPixmap

    This means that there is more code influencing your vector tiles, since more is drawn then is filled in the code you posted so far.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. The following user says thank you to high_flyer for this useful post:

    LuckyBlade (13th January 2011)

  7. #6
    Join Date
    Dec 2010
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Probem Tiling an image with QPixmap

    Holy maccaroni!
    I fixed it.

    I changed
    Qt Code:
    1. for(int i = 0;i != goal;i++) {
    2. sourceVector->append(new Tile(rect,i,originalImage.copy(rect)));
    3.  
    4. if(rect.x() + 32 >= originalImage.width()) {
    5. rect.setY(rect.y() + 32);
    6. rect.setX(0);
    7. }else
    8. rect.setX(rect.x() + 32);
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

    to

    Qt Code:
    1. for(int i = 0;i != goal;i++) {
    2. sourceVector->append(new Tile(rect,i,originalImage.copy(rect)));
    3.  
    4. if(rect.x() + 32 >= originalImage.width()) {
    5. rect.moveTop(32 + rect.y());
    6. rect.moveLeft(0);
    7. }else
    8. rect.moveLeft(32 + rect.x());
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 
    Everything works fine!

  8. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Probem Tiling an image with QPixmap

    If you had used my code from post 4 you'd had that solved since I was using setTopLeft().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. #8
    Join Date
    Dec 2010
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Probem Tiling an image with QPixmap

    Yeah you're right. I just didn't thought that setX() or setY() would cause the problem.
    Well...Now I know better

Similar Threads

  1. OpenGL Image Tiling Interpolation Problem
    By Halcom in forum Qt Programming
    Replies: 1
    Last Post: 22nd December 2010, 13:41
  2. using QPixmap to transparent image
    By sophister in forum Qt Programming
    Replies: 2
    Last Post: 8th July 2010, 13:06
  3. QImage Non-Standard Format Probem
    By photo_tom in forum Qt Programming
    Replies: 3
    Last Post: 19th February 2010, 08:06
  4. Getting image file from QPixmap
    By di_zou in forum Qt Programming
    Replies: 2
    Last Post: 5th October 2009, 16:20
  5. add(draw) an icon(or image) to a QPixmap?
    By ascii in forum Qt Programming
    Replies: 4
    Last Post: 20th November 2008, 12:44

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.