My goal is to print a QImage which consists of random RGB values. However, I got this error:
No member named 'graphicsView' in 'Ui::MainWindow'
My code is here:
int sizeX = 300; int sizeY = 300;
QImage img = QImage(sizeX, sizeY, QImage::Format_RGB32);
for(int i=0; i<sizeX; i ){
for(int j=0; j<sizeY; j ){
img.setPixel(i, j, qRgb(rand()%6, rand()%6, rand()%6));
}
}
QGraphicsScene *graphic = new QGraphicsScene(this);
graphic->addPixmap(QPixmap::fromImage(img));
ui->graphicsView->setScene(graphic);
m_ig = new ImageGenerator;
connect(m_ig, &ImageGenerator::sigTest, this, &MainWindow::slotTest);
Thanks. Best regards!
CodePudding user response:
- Make sure that
Graphics View
widget is added to your MainWindow form (usually mainwindow.ui file) in Design section of QtCreator. - Check if its
objectName
is actually graphicsView. - Try to rebuild your project.