Two question about QGraphicsView , Thanks
1:Why I have to call setHorizontalScrollBarPolicy(Qt:crollBarAlwaysOff) to disable scrollbar, otherwise they will show even the view equal scene.
2:After call fitInView in resizeEvent, there is always a margin in view. what should I do?
MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),
ui(new Ui::MainWindow),myView(new View)
this->myScene = new QGraphicsScene;
//why I have to call these function to diable scrollbar,otherwise they will show no matter the view and scene size
void MainWindow::resizeEvent(QResizeEvent *event)
//if I call this fitInView, there will be a margin in view. why
you might try to replace
The QGraphicsView is not the widget that actually contains the scene, because the QGraphicsView also manages the scrollbars. The scene is drawn in the viewport widget, which is a little smaller than the QGraphicsView.
I hope this helps. Let me know if it did not.