Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to change computer name using QT
Forum Update on Monday, May 27th 2025

How to change computer name using QT

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 5 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    novell86
    wrote on 30 Jul 2018, 05:12 last edited by novell86
    #1

    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...

    R J 2 Replies Last reply 30 Jul 2018, 05:44
    0
    • N novell86
      30 Jul 2018, 05:12

      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...

      R Offline
      R Offline
      Ratzz
      wrote on 30 Jul 2018, 05:44 last edited by
      #2

      @novell86

      Can you show me how you have done it?

      --Alles ist gut.

      N 1 Reply Last reply 30 Jul 2018, 05:53
      1
      • 6 Offline
        6 Offline
        6thC
        wrote on 30 Jul 2018, 05:50 last edited by
        #3

        @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#machineHostName

        To 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).aspx

        Someone 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.

        1 Reply Last reply
        4
        • R Ratzz
          30 Jul 2018, 05:44

          @novell86

          Can you show me how you have done it?

          N Offline
          N Offline
          novell86
          wrote on 30 Jul 2018, 05:53 last edited by
          #4

          @Ratzz ,

          Here:

                  QHostInfo qhi = QHostInfo::fromName(QHostInfo::localHostName());
                  qhi.setHostName(QString("newName"));
          
          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 30 Jul 2018, 06:21 last edited by
            #5

            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.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • N novell86
              30 Jul 2018, 05:12

              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...

              J Online
              J Online
              JonB
              wrote on 30 Jul 2018, 06:45 last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • N Offline
                N Offline
                novell86
                wrote on 30 Jul 2018, 08:18 last edited by
                #7

                Thank you, guys.

                I think the 6thC'th decision will help me.

                Solved.

                1 Reply Last reply
                1

                1/7

                30 Jul 2018, 05:12

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved