I created the simplest Gui with only one button to read and show an image using Qt, the slot of the button is:
void MainWindow::on_pushButton_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open image"),
tr("."),
tr("Image Files (*.png *.jpg *.jpeg *.bmp * .tif)"));
image= cv::imread(fileName);
cv::namedWindow("Original Image");
cv::imshow("Original Image", image);
}
I have the following error:
error: invalid initialization of reference of type 'const string& {aka const std::basic_string<char>&}' from expression of type 'QString'
image= cv::imread(fileName);
^
How to use successfully the QFileDialog class to pass a valid path to the imread?