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

    RatzzR JonBJ 2 Replies Last reply
    0
    • N novell86

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

      RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on last edited by
      #2

      @novell86

      Can you show me how you have done it?

      --Alles ist gut.

      N 1 Reply Last reply
      1
      • 6thC6 Offline
        6thC6 Offline
        6thC
        wrote on 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
        • RatzzR Ratzz

          @novell86

          Can you show me how you have done it?

          N Offline
          N Offline
          novell86
          wrote on last edited by
          #4

          @Ratzz ,

          Here:

                  QHostInfo qhi = QHostInfo::fromName(QHostInfo::localHostName());
                  qhi.setHostName(QString("newName"));
          
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on 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

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

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • N Offline
                N Offline
                novell86
                wrote on last edited by
                #7

                Thank you, guys.

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

                Solved.

                1 Reply Last reply
                1

                • Login

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