qt load image
1. set up a Qt widget Application
2. next, add the QPainter class header to mainwindow.h
#include <QPatiner>
3. After that, declare the paintEvent() virtual function like to
virtual void paintEvent(QPaintEvent *event);
4. New File -> Qt -> Qt Resource File -> resources
copy what do you want to load kitty.png in resources.
5. In mainwindow.cpp load image file using the QImage class:
void MainWindow::paintEvent(QPaintEvent *event) {
QImage image;
image.load(":/kitty.png");
QPainter.drawImage(QPoint(10, 10), image);
}
6. Compile and run the program.