Solved How to change computer name using QT
-
Hi all!
I am starting in qt programming, and want to know how to change computer name with using of this framework. I have tried to execute QHostInfo::setHostName, but it does not take some effect... -
Can you show me how you have done it?
-
@novell86 said in How to change computer name using QT:
QHostInfo::setHostName
I'm not sure that does what you think, I haven't really played there, I just use addresses.
I'm pretty sure that HostInfo is more for querying the connection endpoint and not an api to change the netbios name or anything.http://doc.qt.io/qt-5/qhostinfo.html#localHostName
http://doc.qt.io/qt-5/qsysinfo.html#machineHostNameTo do that you could maybe implement OS calls:
https://linux.die.net/man/2/sethostname
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724931(v=vs.85).aspxSomeone else may come along with something more solid... that's where I'd be looking, maybe search Qt code for api calls like that? Dunno. Pretty sure this isn't the class you are looking for this though.
-
@Ratzz ,
Here:
QHostInfo qhi = QHostInfo::fromName(QHostInfo::localHostName()); qhi.setHostName(QString("newName"));
-
Hi,
@6thC is correct, QHostInfo is used for host name lookups.
Modifying your machine host name is outside of Qt's scope and you will have to use his suggestions.
-
This post is deleted! -
Thank you, guys.
I think the 6thC'th decision will help me.
Solved.