Results 1 to 9 of 9

Thread: Opening an URL that contains accents

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Opening an URL that contains accents

    Hi,

    I've wrote a small application that search for movies in my computer, list them, order the list and display the list to the user (using a a QTreeWidget). When the user double clic a movie name, my application use the QDesktopServices in order to launch the movie.

    Here is the sample code used to launch the movie :
    Qt Code:
    1. QString path_to_a_movie = "N:/The movies/666 - La malédiction";
    2.  
    3. QUrl my_url;
    4. my_url = QUrl::fromLocalFile(path_to_a_movie);
    5.  
    6. QDesktopServices::openUrl(my_url);
    To copy to clipboard, switch view to plain text mode 

    If the [path_to_a_movie] contains accents, like in the example, the movie isn't launched.
    I don't understand how to resolve this problem... Has someone an idea ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Opening an URL that contains accents

    If you construct QStrings this way, you have to set a codec using QTextCodec::codecForCStrings() to let Qt know which codec to use for string literals.

  3. #3
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Opening an URL that contains accents

    In reality, here is the slot that handle double clics on a movie name in the QtreeWidget :

    Qt Code:
    1. void interface_impl::SLOT_launch_movie(QTreeWidgetItem *item, int column)
    2. {
    3. QUrl my_url;
    4. my_url = QUrl::fromLocalFile(item->text(1));
    5.  
    6. QDesktopServices::openUrl(my_url);
    7. }
    To copy to clipboard, switch view to plain text mode 

    So the QString is directly returned by a QTreeWidgetItem, and I suppose - but I don't know - that there is no char* / QByteArray convertion

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Opening an URL that contains accents

    Are those strings displayed properly in the QTreeWidget?

  5. #5
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Opening an URL that contains accents

    Yes, they are

    Perhaps the openURL function has not been written to accept accents... Like generally there is no accentuation in web URLs.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Opening an URL that contains accents

    Which Qt version do you use?

  7. #7
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Opening an URL that contains accents

    Qt 4.2.3, I will probably use the Qt 4.3 next week.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Opening an URL that contains accents

    It seems that this problem was fixed in Qt 4.3.0: http://trolltech.com/developer/task-...ntry&id=141352

  9. The following user says thank you to jacek for this useful post:

    Nyphel (26th June 2007)

  10. #9
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Opening an URL that contains accents

    Oh yes, thank you for this tip !

Similar Threads

  1. Opening pdf file in Qt application
    By jyoti kumar in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2007, 18:35
  2. Opening file
    By Salazaar in forum Newbie
    Replies: 5
    Last Post: 5th June 2007, 18:15
  3. Opening a Dialog from a MainWindow FileMenu
    By nbkhwjm in forum Newbie
    Replies: 4
    Last Post: 17th April 2007, 12:24
  4. Help with opening many pictures
    By philipp1 in forum Qt Programming
    Replies: 3
    Last Post: 14th October 2006, 00:13
  5. Opening swf file in the default browser
    By munna in forum Qt Programming
    Replies: 16
    Last Post: 5th May 2006, 09:33

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
  •  
Qt is a trademark of The Qt Company.