Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-41729

QUrl::PreferLocalFile is not equal to toLocalFIle

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • 5.6.0 RC
    • 5.3.1
    • Core: URL Handling
    • None
    • Windows 8.1 x64
    • 8dad3bf2121e3ad5e405665fefa28c4d53192bf7

    Description

      On Windows, it seems that we have an extra slash when using toString(QUrl::PreferLocalFile)

      Shouldn't toString() and toLocalFile() return the same result?

      ui->setupUi(this);
      connect(ui->openFileButton, &QPushButton::clicked, this, [=]() {
      	QString fileName = QFileDialog::getOpenFileName(this, "Open a file");
      	ui->stringLineEdit->setText(fileName);
      
      	QUrl url = QUrl::fromLocalFile(fileName);
      	ui->toLocalFileLineEdit->setText(url.toLocalFile());
      	ui->urlLineEdit->setText(url.toString(QUrl::PreferLocalFile));
      });
      

      Produces:

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            krf Kevin Funk
            matthieu Matthieu Bachelier
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes