Results 1 to 7 of 7

Thread: Hardware address

  1. #1
    Join Date
    Dec 2008
    Location
    PUNE (INDIA)
    Posts
    49
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Hardware address

    Hi all Experts,
    I am trying to find the hardware address of my PC.
    I used QNetworkInterface class but i am getting my hardware address BLANK.
    Please give me a hint to do so.
    Thanks & Regards ,

    Vajindar Laddad .
    Trainee Developer.
    (INDIA).
    91+9325014248

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Hardware address

    how do you get an address?
    show us code.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Dec 2008
    Location
    PUNE (INDIA)
    Posts
    49
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hardware address

    Hi ,

    QNetworkInterface interface;
    QString hAddress = interface.hardwareAddress();

    I am new to QtNetworking , I may be wrong.
    Please help .
    Thanks & Regards ,

    Vajindar Laddad .
    Trainee Developer.
    (INDIA).
    91+9325014248

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Hardware address

    works fine for me
    Qt Code:
    1. foreach (const QNetworkInterface &ni, QNetworkInterface::allInterfaces())
    2. qDebug() << ni.hardwareAddress();
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Dec 2008
    Location
    PUNE (INDIA)
    Posts
    49
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hardware address

    I have used the code like this

    QNetworkInterface interface;
    QList<QNetworkInterface> networkList;
    networkList = interface.allInterfaces();
    for(int i=0;i<networkList.count();i++)
    {
    QMessageBox::information(this,"Network Interface",networkList.at(i).hardwareAddress());
    }
    I am getting
    1) 00:00:00:00:00:00
    2) 00:1E:2A:44:8A:34
    3) 00:1E:2A:44:8A:34
    4) 00:21:9B:0B:0A:E4
    5) B2:4F:AC:1D:5B:EB
    6) 56:47:C1:83:9A:52

    Is this correct what i am getting ?
    Thanks & Regards ,

    Vajindar Laddad .
    Trainee Developer.
    (INDIA).
    91+9325014248

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Hardware address

    yes, it is.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. The following user says thank you to spirit for this useful post:

    vajindarladdad (12th November 2009)

  8. #7
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hardware address

    BTW, in Qt land, foreach is easier than the equivalent structure using a standard C for loop

    Look at spirit's code and yours. spirit's is much easier to read and follow. Why write more code when the compiler will do it for you?

  9. The following user says thank you to squidge for this useful post:

    vajindarladdad (12th November 2009)

Similar Threads

  1. how can i get IP address
    By dognzhe in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2009, 06:27
  2. IP address find
    By kpmsivachand in forum Qt Programming
    Replies: 6
    Last Post: 21st February 2009, 19:11
  3. Hardware button access in qtopia
    By sar_van81 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th August 2008, 23:16
  4. IO Control Mechanism (Hardware Data Access)
    By rud_1023 in forum General Programming
    Replies: 2
    Last Post: 23rd October 2006, 13:50
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 23:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.