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. QHostAddress mysterious issue - hidden ip address...
Qt 6.11 is out! See what's new in the release blog

QHostAddress mysterious issue - hidden ip address...

Scheduled Pinned Locked Moved General and Desktop
13 Posts 7 Posters 9.6k Views 1 Watching
  • 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.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by
    #4

    Hi Peppy,

    you probably did not forget to declare b, but left it out in your shortened example.
    I have tried it with Qt 4.7.0 and MSVC installation on Win7 64 bit. In the debugger the string b shows "127.0.0.1".
    So, the problem could be with the way you are checking the content of your string (debugger?). The compiler or OS could be other possibilities, but not very likely.

    Best regards
    koahnig

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Peppy
      wrote on last edited by
      #5

      Ehm...no I didn't forget and also this IP was just an example...

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #6

        [quote author="Peppy" date="1304870048"]Ehm...no I didn't forget and also this IP was just an example...[/quote]

        Then show your complete code please, we cannot guess what you are doing wrong, and you have proven in a couple of threads that you've screwed up some C++ basics from time to time.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • adaitabeheraA Offline
          adaitabeheraA Offline
          adaitabehera
          wrote on last edited by
          #7

          Can any body explain this:

          @qDebug("Host Addess: %s", qPrintable(QHostAddress("010.030.026.123").toString()));@

          output:

          bq. Host Addess: 8.24.22.123

          C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. -- Bjarne Stroustrup

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SetBetterPass
            wrote on last edited by
            #8

            adaitabehera with 0 before number it takes as octal number but displays as decimal

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #9

              [quote author="adaitabehera" date="1364035749"]Can any body explain this:[/quote]
              "Yes":http://en.wikipedia.org/wiki/Octal

              1 Reply Last reply
              0
              • adaitabeheraA Offline
                adaitabeheraA Offline
                adaitabehera
                wrote on last edited by
                #10

                In fact the octal representation should be "0010.0030.0026.0123" which is in decimal "8.24.22.83". You can see only the first 3 octets are treated as octal because they are preceded with 0. How can a Host address be a combination of both octal and decimal? I think validation should include a length check (number of digits) in each octet before deciding it as octal, hexadecimal or decimal.

                C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. -- Bjarne Stroustrup

                1 Reply Last reply
                0
                • adaitabeheraA Offline
                  adaitabeheraA Offline
                  adaitabehera
                  wrote on last edited by
                  #11

                  I came across this problem because my application accepts the IPV4 address from a line edit which has an input mask "000.000.000.000;-". If the address entered is "10-.30-.26-.123", then it works fine.

                  C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. -- Bjarne Stroustrup

                  1 Reply Last reply
                  0
                  • adaitabeheraA Offline
                    adaitabeheraA Offline
                    adaitabehera
                    wrote on last edited by
                    #12

                    forgot to put inside code:

                    @“000.000.000.000;-“. If the address entered is “10-.30-.26-.123”@

                    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. -- Bjarne Stroustrup

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SetBetterPass
                      wrote on last edited by
                      #13

                      why you have "-" chars in adress? if it means any digit you will have problem because there is no 30x or 26x in IP adresses, max is 255...
                      And I am not really sure what your problem is, can you describe it better?
                      And about this:
                      [quote author="adaitabehera" date="1364039601"]How can a Host address be a combination of both octal and decimal? [/quote]
                      That's simple, each number is translated to binary octet so it doesn't matter if it was put in as decimal, octal or hexadecimal number.

                      1 Reply Last reply
                      0

                      • Login

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