Code: Alles auswählen
QImage* image = new QImage("picture.bmp");
QGraphicsScene scene;
scene.addPixmap(QPixmap::fromImage(*image));
this->graphicsView->setScene(&scene);Code: Alles auswählen
QImage* image = new QImage("picture.bmp");
QGraphicsScene scene;
scene.addPixmap(QPixmap::fromImage(*image));
this->graphicsView->setScene(&scene);Code: Alles auswählen
QGraphicsScene scene;
scene.addPixmap(QPixmap("picture.bmp"));Code: Alles auswählen
someWidget::someWidget(QWidget* parent , Qt::WindowFlags flags)
: QWidget(parent, flags)
{
setupUi(this);
QGraphicsScene scene;
scene.addPixmap(QPixmap("picture.bmp"));
this->graphicsView->setScene(&scene);
}Code: Alles auswählen
if (this->graphicsView != NULL) this->graphicsView->setScene(&scene);Ich seh hier echt nicht was ich falsch mache.To visualize a scene, you start by constructing a QGraphicsView object, passing the address of the scene you want to visualize to QGraphicsView's constructor. Alternatively, you can call setScene() to set the scene at a later point.
Du fragst so bedeutungsvoll.Christian81 hat geschrieben:ok, dann eben nochmal...
Schonmal geschaut ob this->graphicsView != NULL ist?
Code: Alles auswählen
if (this->graphicsView != NULL) this->graphicsView->setScene(&scene);
Code: Alles auswählen
QGraphicsScene scene;
scene.addText("Hello, world!");
QGraphicsView view(&scene);
view.show();
Code: Alles auswählen
QGraphicsView view = new QGraphicsView();
view.setScene(&scene);
Code: Alles auswählen
{
setupUi(this);
graphicsView = new QGraphicsView();
graphicsView->setObjectName(QString::fromUtf8("graphicsView"));
graphicsView->setGeometry(QRect(10, 10, 481, 151));
QGraphicsScene scene;
scene.addPixmap(QPixmap("picture.bmp"));
graphicsView->setScene(&scene);
graphicsView->show();
}