Results 1 to 1 of 1

Thread: scrollbars in MaximumSize QGraphicsView

  1. #1
    Join Date
    Feb 2009
    Posts
    18
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default scrollbars in MaximumSize QGraphicsView

    TOPIC MOVED TO QT PROGRAMMING FORUM (please respond there)

    I have a problem with setting the maximumsize of a qgraphicsview.

    I do not want any background canvas area to be visible in the qgraphicsview, so when the window is sized sufficiently large, it should be as in below picture (except without scrollbars.)

    For smaller window sizes, the view can be smaller and scrollbars are required.

    The problem is, I cannot get the scrollbars to disappear for a maxed window, where the maximum qgraphicsview size is limited to the views bounding rectangle:



    Qt Code:
    1. MyMain::MyMain(QWidget *parent):QMainWindow(parent)
    2. {
    3. QIcon OpenIcon = this->style()->standardIcon(QStyle::SP_DirOpenIcon, 0, this);
    4.  
    5. QAction *quit = new QAction("&Quit", this);
    6. QAction *open = new QAction("&Open", this);
    7.  
    8. QMenu *file = this->menuBar()->addMenu("&File");
    9. file->addAction(open);
    10. file->addAction(quit);
    11.  
    12. QToolBar *toolbar = addToolBar("main toolbar");
    13. QAction *open2 = toolbar->addAction(OpenIcon, "Open File");
    14. toolbar->addSeparator();
    15.  
    16. scene = new QGraphicsScene();
    17. scene->addText("Hello, world!",QFont("Helvetica [Cronyx]", 100));
    18. view = new QGraphicsView(scene, this);
    19. scene->itemsBoundingRect();
    20.  
    21. view->setContentsMargins ( 0,0,0,0 );
    22. view->setMaximumSize(view->sceneRect().width()+1,view->sceneRect().height()+1);
    23. //view->setMaximumSize(view->maximumViewportSize()); /* also does not work*/
    24.  
    25. this->setCentralWidget(view);
    26. this->resize(800,300);
    27. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by captiva; 17th February 2009 at 14:08.

Similar Threads

  1. QGraphicsView, unmanaged artifact with scrollbars
    By philw in forum Qt Programming
    Replies: 1
    Last Post: 26th December 2008, 02:58
  2. QGraphicsView and scrollbars
    By godmodder in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2008, 22:34
  3. QEvent for QGraphicsView scrollbars?
    By forrestfsu in forum Qt Programming
    Replies: 9
    Last Post: 2nd December 2006, 07:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.