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[])
{
pixmap.
fill(QColor(255,
0,
0));
scene.addPixmap(pixmap);
view.
setBackgroundBrush(QColor(0,
255,
0));
view.setScene(&scene);
window.setCentralWidget(&view);
window.show();
window.resize(199, 199);
return app.exec();
}
#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();
}
To copy to clipboard, switch view to plain text mode
无标题.png
Anyone can help me? Thanks
Bookmarks