If this is your first visit, be sure to
check out the
FAQ
by clicking the
link above. You may have to
register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
Welcome to
Qt Centre
.
Qt Centre
is a community site devoted to programming in C++ using the
Qt framework
. Over 90 percent of questions asked here gets answered. If you are looking for information about Qt related issue —
register
and post your question.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our
free
community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please,
join our community today
!
If you have any problems with the registration process or your account login, please
contact us
.
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?
Qt Code:
Switch view
#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);
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
I want to use two GraphicsView , when I set scrollbarvalue , I want to move both of them.
How can I do it.
Connect one scrollbar's valueChanged(or similar) signal to another scroll bar's setValue(or similar) slot.