user8340050
user8340050

Reputation:

browse ftp folder with QFileDialog

I want to use QFileDialog to browse network shared folder over ftp. But it opens local file dialog rather than ftp dialog. My code below:

QUrl url = QUrl("ftp//10.0.0.3:21");
QUrl file = QFileDialog::getOpenFileUrl(this,tr("Select File"),url,"img(*.tiff *.tif *.txt *)");

Why this?

Upvotes: 0

Views: 844

Answers (1)

Pavan Chandaka
Pavan Chandaka

Reputation: 12731

Like " MrEricSir", you have to give ftp://.

To set up a ftp URL call below function before passing the URL to QFileDialog::getOpenFileUrl

QUrl::setScheme(const QString &scheme)

The below documentation link has an example explaining and how to set the scheme. http://doc.qt.io/qt-5/qurl.html#setScheme

QUrl url = QUrl("ftp://10.0.0.3:21");
url.setScheme("ftp");

Upvotes: 1

Related Questions