#include <QtDebug>
QList<QHostAddress> addrlist = QNetworkInterface::allAddresses();
foreach(QHostAddress addr, addrlist){
qDebug() << addr.toString();
}
/* window QUrl kommt mit file:// nicht zurecht je nach version darum forciere ich wenn es nicht was wom netz ist */
QString DesktopFile( QString fullFileName )
{
#if defined Q_WS_MAC
return fullFileName;
#endif
#if defined Q_WS_X11
return fullFileName;
#endif
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:///");
}
}
void Dav_Main::OpenDesktop( QUrl loc )
{
qDebug() << "### OpenDesktop ............." << loc;
qDebug() << "### OpenDesktop ............." << loc.toString();
#if defined Q_WS_WIN
QString winbuh = DesktopFile(loc.toString());
qDebug() << "### winbuh ............." << winbuh;
bool wr = QDesktopServices::openUrl(QUrl(winbuh));
if (!wr) {
QMessageBox::warning(this, tr("Error"),tr("Unable to open file or dir %1").arg(loc.toString()));
}
return;
#endif
bool r = QDesktopServices::openUrl(loc);
if (!r) {
QMessageBox::warning(this, tr("Error"),tr("Unable to open file or dir %1").arg(loc.toString()));
}
}
.........................
speack português italiano deutsch english castellà qt