"C:/Documents and Settings/user/My Documents/Qt Projects/iconTest-build-desktop/https:/www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=1eic6yu9oa4y3&scc=1<mpl=default<mplcache=2"
"C:/Documents and Settings/user/My Documents/Qt Projects/iconTest-build-desktop/http:/www.google.com"
false true
"C:/Documents and Settings/user/My Documents/Qt Projects/iconTest-build-desktop/https:/www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=1eic6yu9oa4y3&scc=1<mpl=default<mplcache=2"
"C:/Documents and Settings/user/My Documents/Qt Projects/iconTest-build-desktop/http:/www.google.com"
false true
To copy to clipboard, switch view to plain text mode
The above is the result that I get when I run your code. My Qt is 4.7.1. So is it a Qt specific problem?
"C:/Qt/ic-build-desktop/https:/www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=1eic6yu9oa4y3&scc=1<mpl=default<mplcache=2"
"C:/Qt/ic-build-desktop/http:/www.google.com"
true true
"C:/Qt/ic-build-desktop/https:/www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=1eic6yu9oa4y3&scc=1<mpl=default<mplcache=2"
"C:/Qt/ic-build-desktop/http:/www.google.com"
true true
To copy to clipboard, switch view to plain text mode
I run another test of your code and get two null icon.
I think I got the reason why I got one non-null icon as in my previous post. I think the reason is the following
previously my build directory was "C:/Documents and Settings/user/My Documents/Qt Projects/iconTest-build-desktop/" which has lots of spaces in the path.
Now it is "C:/Qt/ic-build-desktop/" which don't has any space.
I think this spaces are creating the problem.
Added after 8 minutes:
#include <QApplication>
#include <QFileInfo>
#include <QIcon>
#include <QFileIconProvider>
#include <QtDebug>
int main(int argc, char *argv[])
{
QFileInfo gmail
("https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=1eic6yu9oa4y3&scc=1<mpl=default<mplcache=2");
qDebug() << gmail.absoluteFilePath();
qDebug() << google.absoluteFilePath();
gmail.setFile(gmail.absoluteFilePath()); // this is the trick ...
QIcon gmailIcon
= iconProvider.
icon(gmail
);
QIcon googleIcon
= iconProvider.
icon(google
);
qDebug() << gmailIcon.isNull() << googleIcon.isNull();
return 0;
}
#include <QApplication>
#include <QFileInfo>
#include <QIcon>
#include <QFileIconProvider>
#include <QtDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFileInfo gmail("https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=1eic6yu9oa4y3&scc=1<mpl=default<mplcache=2");
QFileInfo google("http://www.google.com");
qDebug() << gmail.absoluteFilePath();
qDebug() << google.absoluteFilePath();
gmail.setFile(gmail.absoluteFilePath()); // this is the trick ...
QFileIconProvider iconProvider;
QIcon gmailIcon = iconProvider.icon(gmail);
QIcon googleIcon = iconProvider.icon(google);
qDebug() << gmailIcon.isNull() << googleIcon.isNull();
return 0;
}
To copy to clipboard, switch view to plain text mode
I have solved the problem by passing the absoluteFilePath() to the QFileInfo. Now it is returning two null icons as expected. Thanks you very much franz for your help.
Bookmarks