QGraphicsView and Scrolling
Hi. I add line with 5000 pixel into QGraphicsView then I scroll horizontallly but I can not come end of that line . I write my own scrollBar. Code is below
What is my problem . Do you know?
Code:
#include "mainwindow.h"
#include <QtGui>
MainWindow
::MainWindow(QWidget *parent
){
currentPosition = 0;
populateScene();
scene
->addLine
(QLineF(-100,
0,
5000,
0),
QPen(Qt
::green));
/*view1->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);*/
layout->addWidget(view1);
vertical->addWidget(subWidget);
vertical->addWidget(scrollbar);
connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(moveViews(int)));
}
void MainWindow::populateScene()
{
}
void MainWindow:: moveViews(int value)
{
int moveBy = value - currentPosition;
view1->scroll(-moveBy, 0);
view2->scroll(-moveBy, 0);
currentPosition = value;
}
Re: QGraphicsView and Scrolling
Why don't you use the built-in scrollbar of QGraphicsView? The default range of QScrollBar is 0-99. Most likely it doesn't match too well with your view.
Re: QGraphicsView and Scrolling
I want to use two GraphicsView , when I set scrollbarvalue , I want to move both of them.
How can I do it.
Re: QGraphicsView and Scrolling
Re: QGraphicsView and Scrolling
Connect one scrollbar's valueChanged(or similar) signal to another scroll bar's setValue(or similar) slot.
j
Re: QGraphicsView and Scrolling
I am sure that after 9 years of waiting, the OP is absolutely delighted to see this reply.