Code: Alles auswählen
QGraphicsScene *scene = new QGraphicsScene();
scene->setBackgroundBrush(QColor(0, 0, 0));
ViewBox->setScene(scene);Code: Alles auswählen
QGraphicsScene *scene = new QGraphicsScene();
scene->setBackgroundBrush(QColor(0, 0, 0));
ViewBox->setScene(scene);Qt provides four classes for handling image data: QImage, QPixmap, QBitmap and QPicture. QImage is designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap is designed and optimized for showing images on screen. QBitmap is only a convenience class that inherits QPixmap, ensuring a depth of 1. Finally, the QPicture class is a paint device that records and replays QPainter commands
Code: Alles auswählen
scene->setForegroundBrush(QImage(".\bla.png"));Code: Alles auswählen
scene->setForegroundBrush(QBrush(QImage(".\bla.png")));Code: Alles auswählen
scene->addPixmap(QPixmap(".\bla.png"));Code: Alles auswählen
#include <QApplication>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QPixmap>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QGraphicsView view;
QGraphicsScene scene;
view.setScene(&scene);
scene.addPixmap(QPixmap("./test.png"));
view.show();
return app.exec();
}
Funktion gefunden, aber Anwendung falschtheprogrammer12 hat geschrieben:Ah ok! Ich hab die Funktion gefunden:
scene->addPixmap(QPixmap().fromImage(QImage("./bla.png")));
Code: Alles auswählen
QPixmap pix = QPixmap::fromImage( image );