PDA

View Full Version : Unwanted margin inside QGraphicsView with Scrollbars



lpfxyww
20th June 2014, 18:22
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):


#include <QtGui/QApplication>
#include <QMainWindow>
#include <QGraphicsScene>
#include <QGraphicsView>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;

QPixmap pixmap(200, 200);
pixmap.fill(QColor(255, 0, 0));

QGraphicsScene scene(&window);
scene.addPixmap(pixmap);

QGraphicsView view(&window);
view.setBackgroundBrush(QColor(0, 255, 0));
view.setScene(&scene);

window.setCentralWidget(&view);
window.show();
window.resize(199, 199);

return app.exec();
}

10435
Anyone can help me? Thanks