Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGraphicsView and wrap around?
Qt 6.11 is out! See what's new in the release blog

QGraphicsView and wrap around?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paapaa
    wrote on last edited by
    #1

    I'm using Python 2.7 and PyQt.

    Let's say I have a QGraphicsScene and a QGraphicsView and I want to draw simple Ellipses. I want them to wrap around: when I draw a ellipse centered at upper-lef corner of the visible view area, it should be visible in all four corners: a quarter sector in each.

    How to accomplish this with PyQt?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tzander
      wrote on last edited by
      #2

      Wrap around as such doesn't exist in graphicsview. The canvas is of infinite size and the view just provides a small view on that.

      What you might want to do is auto create duplicates of your ellipse and position them at offsets equal to the viewport size.

      1 Reply Last reply
      0
      • U Offline
        U Offline
        utcenter
        wrote on last edited by
        #3

        If you render to a "buffer" it can be implemented fairly easy. Basically you have a 2D image and a 2D offset which divides the image into 4 portions. Then you use those 4 portions to render the offset image. I guess you could do that by subclassing QGraphicsView and reimplementing some functionality, but you will probably have to do it in C++.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Paapaa
          wrote on last edited by
          #4

          I'm very new to PyQt. This would be very easy if I could just draw individual pixels to offscreen buffer and copy it constantly to visible window. But I have no idea how to do it with PyQt.

          Any pointers? Ie.

          1. How to open an offscreen buffer of size widthxheight.
          2. How to draw a pixel to the bugffer?
          3. How to copy it to screen?

          I'm used to doing all by hand :)

          But if the above is not easy, I'll simply use 4 different ellipses when needed. And delete them when there is no wrapping condition.

          1 Reply Last reply
          0
          • U Offline
            U Offline
            utcenter
            wrote on last edited by
            #5

            If it is possible to solve your problem with instancing and symmetry along x and y it would probably be easier, more math, less code.

            Or you can use even a basic widget to draw with QPainter, convert the widget to a QPixmap of the widget's size(), logically divide the pixmap into 4 parts and use resulting QRect's to reconstruct the final image in another pixmap and display it.

            !http://i48.tinypic.com/14in3ew.png(offset)!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved