Results 1 to 2 of 2

Thread: QGraphicsView on Linux vs. Windows

  1. #1
    Join Date
    Sep 2008
    Posts
    3
    Qt products
    Qt4

    Default QGraphicsView on Linux vs. Windows

    I am using a QGraphicsView from Qt 4.3.3 as well as PyQt4 and adding a PixmapItem to the scene and then centering it in the view. In windows it shows up correctly in the view, but in linux it's shifted to the left side of the frame and the pixmap is cut off?

    Does anyone know why the QGraphicsView/Scene is displayed differently in both windows and linux and what I can do to make it appear properly in Linux.

    Thanks.

    Qt Code:
    1. class CanvasView(QtGui.QGraphicsView):
    2.  
    3. def __init__(self, scene):
    4. QtGui.QGraphicsView.__init__(self, scene)
    5.  
    6. horizontalScrollBar = self.horizontalScrollBar()
    7. horizontalScrollBar.hide()
    8.  
    9. verticalScrollBar = self.verticalScrollBar()
    10. verticalScrollBar.hide()
    11.  
    12. class CanvasScene(QtGui.QGraphicsScene):
    13.  
    14. def __init__(self):
    15. QtGui.QGraphicsScene.__init__(self)
    16.  
    17. def set_image(self, pixmap, width, height)
    18. image = pixmap.scaled(QtCore.QSize(x,y),QtCore.Qt.KeepAspectRatio,QtCore.Qt.SmoothTransformation)
    19. pixmap_item = self.addPixmap(image)
    20.  
    21. # Code is added here to get the center point
    22. # and the pixmap item is moved to the center
    23. pixmap_item.setPos(center_x, center_y)
    24.  
    25. self.canvas = CanvasScene(self)
    26. self.canvas.setSceneRect(0,0, 478, 250)
    27.  
    28. self.canvas_view = CanvasView(self.canvas)
    29. self.canvas_view.setParent(self) # parent is set to a QFrame
    30. self.canvas.set_image(pixmap, 300, 250)
    31. self.canvas_view.show()
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 17th September 2008 at 17:25. Reason: missing [code] tags

  2. #2
    Join Date
    Sep 2008
    Posts
    3
    Qt products
    Qt4

    Default Re: QGraphicsView on Linux vs. Windows

    I figured it out, I had to call resize on the viewport. I'm not really sure why I needed to do that, but that seems to work.

Similar Threads

  1. QPalette works differently on windows and linux
    By babu198649 in forum Newbie
    Replies: 3
    Last Post: 6th March 2008, 07:27
  2. Replies: 19
    Last Post: 21st January 2008, 09:13
  3. Replies: 2
    Last Post: 9th June 2007, 19:19
  4. Replies: 2
    Last Post: 30th August 2006, 10:09
  5. Replies: 4
    Last Post: 12th January 2006, 04:16

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.