
Originally Posted by
jacek
Are you sure this creates a valid QUrl object? What does "youhome.isValid()" return? Shouldn't there be "file://" in front of the string?
Now is running .....
If i write a Qurl class i append this small code..... on return value....
{
if (fullFileName.startsWith("http://", Qt::CaseInsensitive) or
fullFileName.startsWith("https://", Qt::CaseInsensitive) or
fullFileName.startsWith("ftp://", Qt::CaseInsensitive) or
fullFileName.startsWith("news://", Qt::CaseInsensitive) or
fullFileName.startsWith("mailto:", Qt::CaseInsensitive) or
fullFileName.startsWith("webdav://", Qt::CaseInsensitive) )
{
return fullFileName;
} else {
return fullFileName.prepend("file:///");
}
}
QString IsNetFile( QString fullFileName )
{
if (fullFileName.startsWith("http://", Qt::CaseInsensitive) or
fullFileName.startsWith("https://", Qt::CaseInsensitive) or
fullFileName.startsWith("ftp://", Qt::CaseInsensitive) or
fullFileName.startsWith("news://", Qt::CaseInsensitive) or
fullFileName.startsWith("mailto:", Qt::CaseInsensitive) or
fullFileName.startsWith("webdav://", Qt::CaseInsensitive) )
{
return fullFileName;
} else {
return fullFileName.prepend("file:///");
}
}
To copy to clipboard, switch view to plain text mode
#include <QDesktopServices>
#define HOME_DIR_YOUR \
qDebug() << "### HOME_DIR_YOUR " << HOME_DIR_YOUR;
QUrl youhome
(HOME_DIR_YOUR.
prepend("file:///"));
/* filee path not open */ qDebug() << "### youhome.toString() " << youhome.toString();
qDebug() << "### youhome.toLocalFile() " << youhome.toLocalFile();
QUrl youhome1
("http://www.qtcentre.org/forum/");
/* running open browser*/
### HOME_DIR_YOUR "C:/Documents and Settings/ppk-it/ale.png"
### youhome.toString() "file:///C:/Documents and Settings/ppk-it/ale.png"
### youhome.toLocalFile() "C:/Documents and Settings/ppk-it/ale.png"
#include <QDesktopServices>
#define HOME_DIR_YOUR \
QString( "%1/ale.png" ).arg( QDir::homePath())
qDebug() << "### HOME_DIR_YOUR " << HOME_DIR_YOUR;
QUrl youhome(HOME_DIR_YOUR.prepend("file:///")); /* filee path not open */
qDebug() << "### youhome.toString() " << youhome.toString();
qDebug() << "### youhome.toLocalFile() " << youhome.toLocalFile();
QUrl youhome1("http://www.qtcentre.org/forum/"); /* running open browser*/
QDesktopServices::openUrl (youhome);
### HOME_DIR_YOUR "C:/Documents and Settings/ppk-it/ale.png"
### youhome.toString() "file:///C:/Documents and Settings/ppk-it/ale.png"
### youhome.toLocalFile() "C:/Documents and Settings/ppk-it/ale.png"
To copy to clipboard, switch view to plain text mode
Bookmarks