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 converting an int to a QString?
Forum Updated to NodeBB v4.3 + New Features

how to converting an int to a QString?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 2.7k 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.
  • N Offline
    N Offline
    nischu
    wrote on 2 Sept 2016, 13:43 last edited by
    #1

    Hello there, i need a call of QLabel.setText() which displays an int type.
    I have tried: my_label->setText( QString(std::to_string(my_int))); and got this error message:

    /home/sven/develop/Qt/tictactoe/configurationdialog.cpp:40: error: no matching function for call to ‘QString::QString(std::__cxx11::string)

    I have no clue how i could convert ad hoc from 'int' to 'QString'.

                                                                      ^
    
    R 1 Reply Last reply 2 Sept 2016, 13:45
    0
    • N nischu
      2 Sept 2016, 13:43

      Hello there, i need a call of QLabel.setText() which displays an int type.
      I have tried: my_label->setText( QString(std::to_string(my_int))); and got this error message:

      /home/sven/develop/Qt/tictactoe/configurationdialog.cpp:40: error: no matching function for call to ‘QString::QString(std::__cxx11::string)

      I have no clue how i could convert ad hoc from 'int' to 'QString'.

                                                                        ^
      
      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 2 Sept 2016, 13:45 last edited by
      #2

      @nischu
      QString::number()

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      3
      • N Offline
        N Offline
        nischu
        wrote on 2 Sept 2016, 13:49 last edited by
        #3

        Thanks. I should dive deeper into Qt Core facilities :)

        1 Reply Last reply
        0
        • N Offline
          N Offline
          nischu
          wrote on 2 Sept 2016, 14:07 last edited by
          #4

          @raven-worx
          Should be rather
          QString::setNum(), or at my case: QLabel::setNum()

          1 Reply Last reply
          0
          • V Offline
            V Offline
            VRonin
            wrote on 2 Sept 2016, 14:13 last edited by
            #5

            <Rude>http://bfy.tw/7VrJ</Rude>

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            N 1 Reply Last reply 2 Sept 2016, 17:09
            0
            • V VRonin
              2 Sept 2016, 14:13

              <Rude>http://bfy.tw/7VrJ</Rude>

              N Offline
              N Offline
              nischu
              wrote on 2 Sept 2016, 17:09 last edited by
              #6

              Sorry, I've overlooked the static section of QString doc. :-(

              1 Reply Last reply
              0

              1/6

              2 Sept 2016, 13:43

              • Login

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