Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Incorrect Scene Size Dimensions when called from Custom QGraphicsWidget
oracle3001 last edited by
I have the following simple setup,
@int main(int argc, char argv)
QApplication app(argc, argv);
QGraphicsScene scene = new QGraphicsScene();
QCustomGraphicsView* customGraphicsView= new QCustomGraphicsView(scene) ;
QCustomGraphicsWidget* customWidget = new QCustomGraphicsWidget(); scene->addItem(customWidget) ; customGraphicsView->show() ; return app.exec();
QCustomGraphicsView size is set within its own constructor (and is based up a larger window). It doesn't have a frame and scrollbars are disabled.
@void QCustomGraphicsWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QGraphicsWidget::mouseMoveEvent(event); // move the item... qDebug() << QString("Mouse Move Event") ; QRectF sceneRect = scene()->sceneRect() ; qDebug("geo: %f %f", sceneRect .width(), sceneRect .height());
And the sceneRect variable does not return the correct size of the scene that it has been added to.
What I am trying to do, is enforce that when my QCustomGraphicsWidget is moved around the scene that when it gets to the edge, it can't be dragged beyond that and out of sight.