mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-09 03:50:29 -08:00
example 'cl-repl': several revisions and small improvements
This commit is contained in:
parent
9037da0769
commit
aaa98e00b8
11 changed files with 89 additions and 17 deletions
|
|
@ -3,6 +3,8 @@
|
|||
#include <QtDebug>
|
||||
#include <QTextDocument>
|
||||
#include <QQuickTextDocument>
|
||||
#include <QNetworkInterface>
|
||||
#include <QHostAddress>
|
||||
|
||||
#ifdef PLUGIN
|
||||
#include <ecl_fun_plugin.h>
|
||||
|
|
@ -306,4 +308,29 @@ QVariant QT::textDocument(const QVariant& vDocument) {
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
#if (defined Q_OS_ANDROID) || (defined Q_OS_IOS)
|
||||
QVariant QT::localIp() {
|
||||
// Tries to find the local network address. If the result is not unique,
|
||||
// a null value is returned (no guesses).
|
||||
QStringList ips;
|
||||
QList<QHostAddress> addresses = QNetworkInterface::allAddresses();
|
||||
for (QHostAddress adr : qAsConst(addresses)) {
|
||||
if (adr.protocol() == QAbstractSocket::IPv4Protocol) {
|
||||
QString str(adr.toString());
|
||||
if (str.startsWith("192.168.1.")) {
|
||||
return str;
|
||||
}
|
||||
if (str != "127.0.0.1") {
|
||||
ips << str;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ips.length() == 1) {
|
||||
return ips.first();
|
||||
}
|
||||
qDebug() << "multiple IPs found:\n" << ips.join("\n");
|
||||
return QVariant();
|
||||
}
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue