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]textBrowser->setText or textEdit->setText Using String Array

[SOLVED]textBrowser->setText or textEdit->setText Using String Array

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 6.1k Views
  • 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.
  • M Offline
    M Offline
    MrNoway
    wrote on 2 Dec 2012, 13:07 last edited by
    #1

    This Forum seems to be pretty vivid,
    so I hope you can help me with this little problem.

    I do have an array:

    @QString key_storage[20]@

    filled with some values.

    I want them all to be displayed in a textBrowser or textEdit field.

    @ while (j <=i)
    {
    ui.textBrowser->setText( key_storage[j] );

    j++;}@

    if I do like this, it works but the next array is replaced with the before one.

    so I can always just show one line.
    But I want them all.

    How can i do this?

    I am looking for something like a textBrowser->addText command

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on 2 Dec 2012, 13:11 last edited by
      #2

      Use QTextEdit::append or build a QString from all strings and then call setText once.

      And once again: Don't use C-Arrays here. You're shooting yourself in the foot. Use QStringList. It could be that easy:
      @
      QStringList strings;
      strings << "line one" << "line two";
      yourTextEdit->setText(strings.join("\n"));
      @

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MrNoway
        wrote on 2 Dec 2012, 13:26 last edited by
        #3

        hi, thanks for your quick respond,

        I am gonna try it right away.

        okay I will try avoid C-Arrays,
        but thats what I learned the last 2 semesters,
        its hard just to forget it, what those proferssors tried to burn into your mind. -__-

        thank you once again

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MrNoway
          wrote on 2 Dec 2012, 13:37 last edited by
          #4

          great, that was exactly what I was looking for

          @ QStringList strings;
          for (int b = 0; b<=20; b++){
          strings << key_storage[b]; }
          ui.textEdit->setText(strings.join("\n"));@

          gonna mark is as solved

          1 Reply Last reply
          0

          1/4

          2 Dec 2012, 13:07

          • Login

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