int main(int argc, char** argv){ QApplication app(argc, argv); QLabel lbl; QPixmap pix("mira.jpg"); lbl.setPixmap(pix); lbl.show(); return app.exec();}
pix.load("mira.jpg");
C++ (Qt)int main(int argc, char** argv){ QApplication app(argc, argv); QLabel lbl; QString imgfile = QCoreApplication::applicationDirPath() + QDir::separator() + "mira.jpg"; //full path to mira.jpg QPixmap pix(imgfile); lbl.setPixmap(pix); lbl.show(); return app.exec();}
virtual void mousePressEvent(QMouseEvent* pe) { QPainter painter; painter.drawPoint(pe->pos()); }
C++ (Qt)...QPixmap pixmap(100, 100);QPainter painter(&pixmap);...
PaintArea : public QWidget {virtual void paintEvent(QPaintEvent*){} //drawing virtual void mousePressEvent(QMouseEvent* pe) QPainter painter(this); painter.drawPoint(pe->pos()); }}