
Originally Posted by
wysota
Is it really a minimal compilable example?
So what is the incorrect behaviour? It seems to work correctly for me (KDE 3.5.4) I drag the file onto the label, drop it and its contents appear in the text box below.
BTW. Placing files on peoples' desktops is not something I'd call "nice". Please try to avoid it next time when posting an example.
on my KDE not running ... kubuntu qt4.1 packace from debs url
it display inside qtextedit "file:///path/blabla.xx"... as text not read inside
i suppose toLocalFile(); is os different....
void OpenMyFile
::Grabdata(const QMimeData *data
) {
if (!data) {
return;
}
QList<QUrl> urlelist;
if (data->hasUrls()) {
urlelist = data->urls();
for ( int i = 0; i < urlelist.size(); ++i ) {
QString unfilone
= urlelist.
at(i
).
toLocalFile();
/////qDebug() << "### url " << unfilone;
if (f.exists()) {
OpenFile(unfilone);
}
}
}
}
void OpenMyFile::Grabdata(const QMimeData *data)
{
if (!data) {
return;
}
QList<QUrl> urlelist;
if (data->hasUrls()) {
urlelist = data->urls();
for ( int i = 0; i < urlelist.size(); ++i ) {
QString unfilone = urlelist.at(i).toLocalFile();
/////qDebug() << "### url " << unfilone;
QFile f(unfilone);
if (f.exists()) {
OpenFile(unfilone);
}
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks