Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QGraphicsView shifted its contents when scrollbar appear
sngqt last edited by
I noticed that QGraphicsView shifted its contents by few pixels upward when scrollbar appear. Is there anyway to avoid such behavior?. I want the scrollbar appear but the contents should stay at the same position.
Here is the sample codes:
QApplication a(argc, argv); QGraphicsView v; QGraphicsScene scene; v.show(); v.setScene(&scene); QBrush brush(Qt::red); scene.addRect(0,0,1000,80,QPen(),brush); //When you reduce the width of v, scrollbar appear but contents shifted upward. return a.exec();
I will be very appreciated if someone could help.
Joel Bodenmann last edited by
The easiest solution is to always show the scrollbars, if that is acceptable:
Otherwise I guess you won't have any other option besides manually translating the viewport.
sngqt last edited by sngqt
Thanks for your suggestion.
How would I manually translate the view port ?
A snippet could help. Thanks