[PyQt] Rotate QMainWindow 180deg
maurizio.berti at gmail.com
Fri May 11 11:59:15 BST 2018
You are getting it wrong: there can be only one central widget, and
obviously setting it for a QGraphicsProxyWidget doesn't make any sense.
Use the QGraphicsView as the central widget, then add the Browser_Widget to
This has some drawbacks, expecially in your case: the widget will not have
direct access to the main window (and vice versa), which is most important
for layout and size reasons.
A partial solution might be to set the minimum size of the QGraphicsView
viewport to the minimumSizeHint of the Browser_Widget and implement the
resizeEvent of the QGraphicsView to notify the QGraphicsProxyWidget about
the size changes.
To prevent graphics, layout and alignment problems, set the frameShape of
the QGraphicsView to NoFrame and the scrollbar policy to scrollBarAlwaysOff.
Also, be aware that subclasses of QAbstractScrollArea (expecially item
views such as QListView, etc) have issues when used within a proxy widget,
most of them regarding mouse events. In my experience I had to reimplement
wheel events, some QHeaderView methods and other things related to mouse
hovering. And remember that popup widgets like QComboBoxes will show their
views within the scene, so if you have popup views that go outside the
"main" widget margins, they will be outside the graphics scene, thus will
not be completely shown.
Good luck! ;-)
2018-05-11 11:37 GMT+02:00 Rob <rob at pixelinspiration.net>:
> For mad reasons I've been asked to see if I can get an app to toggle itself
> by 180 degrees. Bit of googling came up with these two posts (in C++):
> Which both suggest the same approach using QGraphicsProxyWidget,
> QGraphicsScene and QGraphicsView which I've tried to implement like this
> (very cut down code):
> class MainWindow(QMainWindow):
> def __init__(self, url):
> self.browserWidget = Browser_Widget(self, url)
> self.scene = QGraphicsScene()
> self.view = QGraphicsView(self)
> self.proxy = self.scene.addWidget(self.centralWidget())
> Which gives me this small white rectangle at the top left:
> Thanks for any thoughts.
> Sent from: http://python.6.x6.nabble.com/PyQt-f1792048.html
> PyQt mailing list PyQt at riverbankcomputing.com
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt