Results 1 to 2 of 2

Thread: When drop a file from shared folder, the path could not be correctly obtained in QT

  1. #1
    Join Date
    Aug 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default When drop a file from shared folder, the path could not be correctly obtained in QT

    Hi,
    I need to help to solve this problem that the path is not correctly obtained. I am running the QT in Window7 environment.

    I shared a folder from another computer and opened the folder using window. The path of the file is
    \\yw-desk3\users\yw\qttest\videodata\0000.bmp.
    When I drap and drop the file to my qt applications, it only get
    users\yw\qttest\videodata\0000.bmp
    So the file cannot be opened since the path is not correct. How should I fix the problem? Here is the code that I used.

    void MainWindow::dropEvent(QDropEvent *event)
    {
    const QMimeData *mimeData = event->mimeData();

    if (!mimeData->hasUrls() || mimeData->urls().size() < 1)
    return;


    // In both cases, we need to remove the leading '/' that
    // remains after 'file:///C:/' is truncated to '/C:/'

    QString path = mimeData->urls().at(0).path().remove(0, 1);
    openColorComponent(path);
    }

    Thanks

    Frank

  2. #2
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: When drop a file from shared folder, the path could not be correctly obtained in

    you can use QUrl::toLocalFile() to get file path from a url.

Similar Threads

  1. Replies: 3
    Last Post: 31st March 2011, 13:10
  2. Replies: 1
    Last Post: 2nd December 2010, 14:47
  3. Drop not working correctly
    By rippa in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2008, 15:13
  4. Qt4: How to get the Common Application Data folder path?
    By Ankitha Varsha in forum Qt Programming
    Replies: 10
    Last Post: 21st October 2008, 12:14
  5. Path to the previous folder
    By Zergi in forum Newbie
    Replies: 2
    Last Post: 15th July 2008, 18:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.