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. Print numbers 1 to 10 in GUI [SOLVED] - [Solucionado]
Forum Updated to NodeBB v4.3 + New Features

Print numbers 1 to 10 in GUI [SOLVED] - [Solucionado]

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.5k 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.
  • S Offline
    S Offline
    Sadalsuud
    wrote on last edited by
    #1

    Hello, I want display in GUI a numbers 1 to 10 and I have this code:

    @
    QString rta;
    for(int i = 0; i < 10; i++){
    rta += i;
    rta += "\n";
    }
    ui->tablero->setText(rta);

    @

    I display in a QTextEdit but this code show symbols as ASCII ...not numbers :S what happened?

    I need use a QString for concatenate.

    Any comments suggestion recommendation? ... thanks for the time, I'm new to QT as 3 days ago I met him and I'm testing it

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mkuettler
      wrote on last edited by
      #2

      Try replacing
      @
      rta += i;
      @

      with
      @
      rta += QString::number(i);
      @

      i is not automatically converted to a string containing the number. Instead the compiler will convert the int to a QChar (I think), which is not what you want.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sadalsuud
        wrote on last edited by
        #3

        Thank you very much indeed :D

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mkuettler
          wrote on last edited by
          #4

          I'm glad I was able to help :)
          Please mark the thread as solved (simply edit it and add something like [SOLVED] to the title).

          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