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. [Solved] Conversion from DWORD to QString
Forum Updated to NodeBB v4.3 + New Features

[Solved] Conversion from DWORD to QString

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 10.9k 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.
  • Z Offline
    Z Offline
    zolidznake
    wrote on last edited by
    #1

    Hi,

    I have a function wich returns a DWORD

    i am unable to convert it to std::string or Qstring

    any help would be appreciated

    Thank You

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hpollak
      wrote on last edited by
      #2

      DWORD is no standard C++ datatype, it is Microsoft specific, but according doe "MSDN":http://msdn.microsoft.com/en-us/library/cc230318(v=prot.20).aspx it isdefined as:
      unsingend long, so you can:

      qstr = QString::number(dw);

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MuldeR
        wrote on last edited by
        #3

        Or if you need a plain C string:

        @DWORD dw = 42;
        char str[128];
        snprintf(str, 128, "%u", dw)@

        Or the C++ way:

        @DWORD dw = 42;
        std::stringstream sstr;
        sstr << dw;
        std::string str = sstr.str();@

        My OpenSource software at: http://muldersoft.com/

        Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

        Go visit the coop: http://youtu.be/Jay...

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          zolidznake
          wrote on last edited by
          #4

          on your line 2 and 4 i get the following errors :(

          main.cpp:1699: error: C2079: 'sstr' uses undefined class 'std::basic_stringstream<_Elem,_Traits,_Alloc>'
          with
          [
          _Elem=char,
          _Traits=std::char_traits<char>,
          _Alloc=std::allocator<char>
          ]

          main.cpp:1701: error: C2228: left of '.str' must have class/struct/union
          type is 'int'

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            You've got some "include" missing.

            (Z(:^

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zolidznake
              wrote on last edited by
              #6

              in can't figure what is the lib i should include ...

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                @
                #include <sstream>
                @

                Uncle google has answers to many secrets...

                (Z(:^

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  zolidznake
                  wrote on last edited by
                  #8

                  thank you again !

                  1 Reply Last reply
                  0
                  • sierdzioS Offline
                    sierdzioS Offline
                    sierdzio
                    Moderators
                    wrote on last edited by
                    #9

                    Pleasure. Please add "[Solved]" to the beginning of the topic's title if you consider this to be solved.

                    (Z(:^

                    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