I have the following problem with scrollbars in a graphical representation. My application accepts a PDF file and creates (in some way) a QImage from it. Then QImage converted to QPixmap , which is used to create a QGraphicsScene , and from QGraphicsScene I create a QGraphicsView . QGraphicsView added to the central widget and displayed.
The code looks something like this:
QImage image; image = loadImage(path); QPixmap pixmap; pixmap.convertFromImage(image); scene = new QGraphicsScene(this); scene->addPixmap(pixmap); view = new QGraphicsView(scene); textEdit = new QTextEdit(this) QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(view); layout->addWidget(textEdit); QWidget *widget = new QWidget; widget->setLayout(layout); setCentralWidget(widget);
In the application, the view value is updated every time a PDF file is modified. Now the problem is that the thing in the PDF can also be resized, and the scroll bars are mixed up. I want the scrollbars after the upgrade to be in position, so that I will see the same part of the PDF file as before the upgrade.
Can you give me some tips on how to do this? I searched for this problem, but so far nothing has worked in my case (maybe I'm wrong too).
Thank you for your responses!
source share