Results 1 to 1 of 1

Thread: Unwanted margin inside QGraphicsView with Scrollbars

  1. #1
    Join Date
    Nov 2013
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Unwanted margin inside QGraphicsView with Scrollbars

    Hi,
    I'm drawing something with the Qgraphicsview framework. The view hold a scene with a single Item. The scene's height is equivalent to the item's. But when I try to resize the view to its minimum height, there's a gap(the green part) between the content and the view's boarder, shown in the attached photo.
    Here is a simpler version of my code(I replaced the item with a pixmap):
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QMainWindow>
    3. #include <QGraphicsScene>
    4. #include <QGraphicsView>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication app(argc, argv);
    9. QMainWindow window;
    10.  
    11. QPixmap pixmap(200, 200);
    12. pixmap.fill(QColor(255, 0, 0));
    13.  
    14. QGraphicsScene scene(&window);
    15. scene.addPixmap(pixmap);
    16.  
    17. QGraphicsView view(&window);
    18. view.setBackgroundBrush(QColor(0, 255, 0));
    19. view.setScene(&scene);
    20.  
    21. window.setCentralWidget(&view);
    22. window.show();
    23. window.resize(199, 199);
    24.  
    25. return app.exec();
    26. }
    To copy to clipboard, switch view to plain text mode 
    无标题.png
    Anyone can help me? Thanks
    Last edited by anda_skoa; 20th June 2014 at 18:26. Reason: missing [code] tags

Similar Threads

  1. Replies: 0
    Last Post: 19th March 2013, 10:47
  2. qGraphicsView scrollbars not getting smaller
    By danbelsey in forum Newbie
    Replies: 0
    Last Post: 1st August 2011, 16:43
  3. QGraphicsView unwanted margin
    By hheld in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2011, 17:16
  4. scrollbars and qgraphicsview
    By captiva in forum Qt Programming
    Replies: 13
    Last Post: 20th February 2009, 12:00
  5. QGraphicsView and scrollbars
    By godmodder in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2008, 22:34

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.