QT QGraphicsScene with QLabel and QPixmap
<p>I have a QGraphicsView, in that I have a QGraphicsScene, in that I have a QLabel and I set a .png picture as QPixmap into the QLabel. The .png is set in background.qrc resource file.
My QLabel's size is 600x400. Without the pixmap it's okay, the QGraphicsScene's size is 600x400 too. But when I set the pixmap to the QLabel and scale it, it fails.
The QLabel's size is the same, the pixmap is scaled well within the QLabel and only visible within it, but the QGraphicsScene adopts the real size of the QPixmap, which is 720x720. So the QLabel is visible with the QPixmap in it's correct size, but there is a gray place around it, since the scene is bigger.
How can I fix this and make it work? I want the QGraphicScene to stay on the size of the QLabel.</p>

<p>Here's the code:</p>

<pre><code>#include "mainwindow.h"
#include "ui_mainwindow.h"
#include &lt;QPixmap&gt;
#include &lt;QGraphicsView&gt;
#include &lt;QGraphicsScene&gt;
#include &lt;QLabel&gt;

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui-&gt;setupUi(this);
    QGraphicsView *myView = new QGraphicsView(this);
    QGraphicsScene *myScene= new QGraphicsScene();
    QLabel *myLabel= new QLabel();
    myLabel-&gt;setBaseSize(QSize(600, 400));
    myLabel-&gt;resize(myLabel-&gt;baseSize());
    myLabel-&gt;setScaledContents(true);
    QPixmap pixmapBackground(":/new/cross.png");
    myLabel-&gt;setPixmap(pixmapBackground);
    myScene-&gt;addWidget(myLabel);
    myView-&gt;setScene(myScene);
    setCentralWidget(myView);
}

MainWindow::~MainWindow()
{
    delete ui;
}
</code></pre>