私はこれで何時間も髪を引っ張っています。ここにスレッドがありますが、何も機能していないようです。QGraphicsView::rect() は幅と高さを返しますが、値left
とtop
値が正しく設定されていません (常に 0 -- スクロール量を無視します)。シーン座標でそれが欲しいのですが、どのシステムからでも簡単に変換できるはずです。何とhorizontalScrollBar()->value()
vert が戻ってきたのかわかりません...意味のないおしゃべりのようです。
@ファブリツィオ:
// created here
void EditorWindow::createScene() {
m_scene = new EditorScene(this);
m_view = new EditorView(m_scene);
setCentralWidget(m_view);
connect(m_scene, SIGNAL(mousePosChanged(QPointF)), this, SLOT(mousePosChanged(QPointF)));
}
/// with this constructor
EditorView::EditorView(QGraphicsScene* scene, QWidget* parent) : QGraphicsView(scene, parent) {
setRenderHint(QPainter::Antialiasing);
setCacheMode(QGraphicsView::CacheBackground);
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
setDragMode(QGraphicsView::NoDrag);
scale(1.0, -1.0); // flip coordinate system so that y increases upwards
fitInView(-5, -5, 10, 10, Qt::KeepAspectRatio);
setInteractive(true);
setBackgroundBrush(QBrush(QColor(232,232,232), Qt::DiagCrossPattern));
}