QGraphicsView doesn't fill the actual space for QGraphicsView?



  • I have a ready form with a QGraphicsView item on it. In the actual MainWindow constructor, I have this:

    @view_ = new QGraphicsView(ui->GraphicsView);@

    In this case view_ is a QGraphicsView pointer found in the private of MainWindow. When I run the program, I see that the the new allocated QGraphicsView only fills up around 1/4th of the available space in the actual GraphicsView. When I set a scene to it, the small QGraphicsView has scroll bars. To fix this, I manually set the size of the allocated QGraphicsView to match the GraphicsView @view_->resize(400, 400);@ But even then when I set a scene bigger than the QGraphicsView, I get scroll bars. So why do I get scroll bars and why isn't the GraphicsView filled with the allocated QGraphicsView? Is it possible to remove the scroll bars and the ability to scroll while still having the ability to use for instance centerOn function of QGraphicsView?


  • Lifetime Qt Champion

    Hi,

    What is ui->GraphicsView ? A QGraphicsView ?

    If so, why are you creating another one ?

    If not, you are just creating a QGraphicsView with a parent. You should put it in a layout in the central widget (or depending on your application, make it the central widget) in order for it to be manager by your QMainWindow


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.