#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;
}
#include "mainwindow.h"
#include <QtGui>
MainWindow::MainWindow(QWidget *parent)
: QWidget(parent)
{
currentPosition = 0;
populateScene();
scene->addLine(QLineF(-100,0,5000,0),QPen(Qt::green));
view1 = new QGraphicsView(scene);
scrollbar = new QScrollBar(Qt::Horizontal, this);
/*view1->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);*/
QVBoxLayout *vertical = new QVBoxLayout(this);
QWidget *subWidget = new QWidget(this);
QHBoxLayout *layout = new QHBoxLayout(subWidget);
layout->addWidget(view1);
vertical->addWidget(subWidget);
vertical->addWidget(scrollbar);
connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(moveViews(int)));
}
void MainWindow::populateScene()
{
scene = new QGraphicsScene;
}
void MainWindow:: moveViews(int value)
{
int moveBy = value - currentPosition;
view1->scroll(-moveBy, 0);
view2->scroll(-moveBy, 0);
currentPosition = value;
}
To copy to clipboard, switch view to plain text mode
Bookmarks