// // Created by CAS-CQZ on 2021/10/24. // #include #include #include int main(int argc, char* argv[]) { QApplication a(argc, argv); QLabel w; QString filename = QFileDialog::getOpenFileName(&w, ("选择图像"), "", ("Images (*.png *.bmp *.jpg *.tif *.GIF )"));//可打开的文件类型 if (filename.isEmpty()) { return 0; } filename = QDir::toNativeSeparators(filename); auto img = new QImage(filename); w.setPixmap((QPixmap::fromImage(*img))); w.show(); return a.exec(); }