2017-07-16 47 views

回答

0

您可以使用QFileDialog獲得給定圖像的路徑:

QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), 
              QDir::currentDirPath() , 
              tr("Images (*.png *.xpm *.jpg)")); 
if (!fileName.isEmpty()) { 
    // Now you can init your sf::image 

} 

SFML官方文檔,可以使用loadFromFile功能

sf::Image image; 
if (image.loadFromFile(filename.toStdString())) { 
    std::cout << "image loaded with success"; 
} 
+0

爲我工作,謝謝! – DzieckoBezZycia