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. Label display issue
Forum Updated to NodeBB v4.3 + New Features

Label display issue

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 2.2k 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.
  • ChrisClC Offline
    ChrisClC Offline
    ChrisCl
    wrote on last edited by
    #1

    Hi all,

    I would like to display the text as below in qlabel in my gui:

    int1
    int2
    int3
    int4
    int5

    what i get now is only 1 line output, the latest output will keep replace the old one.
    how can i get it the new info will pop out in the new line?

    RatzzR 1 Reply Last reply
    0
    • ChrisClC ChrisCl

      Hi all,

      I would like to display the text as below in qlabel in my gui:

      int1
      int2
      int3
      int4
      int5

      what i get now is only 1 line output, the latest output will keep replace the old one.
      how can i get it the new info will pop out in the new line?

      RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on last edited by
      #2

      @ChrisCl
      try appending old ones with new line using \n
      https://forum.qt.io/topic/40297/how-to-add-a-new-line-at-a-particular-position-in-qlabel/2

      --Alles ist gut.

      ChrisClC 1 Reply Last reply
      0
      • jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi!
        You need to change textFormat to RichText and activate wordWrap. And you have to make sure the label has actually a size able to show more than one line. Then you can add rich text with new lines.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • RatzzR Ratzz

          @ChrisCl
          try appending old ones with new line using \n
          https://forum.qt.io/topic/40297/how-to-add-a-new-line-at-a-particular-position-in-qlabel/2

          ChrisClC Offline
          ChrisClC Offline
          ChrisCl
          wrote on last edited by
          #4

          @Ratzz
          Thanks for the ans.
          But i want display different text in the label.
          Is the only way i can do is use different label?
          Like i want to update new information into the label in next line and keep the old info (instead of replace now), can i do it?

          RatzzR jsulmJ 2 Replies Last reply
          0
          • ChrisClC ChrisCl

            @Ratzz
            Thanks for the ans.
            But i want display different text in the label.
            Is the only way i can do is use different label?
            Like i want to update new information into the label in next line and keep the old info (instead of replace now), can i do it?

            RatzzR Offline
            RatzzR Offline
            Ratzz
            wrote on last edited by
            #5

            @ChrisCl
            As above suggested label should be able to show more than one line and set wordWrap with true parameter as show here .

            --Alles ist gut.

            ChrisClC 1 Reply Last reply
            0
            • ChrisClC ChrisCl

              @Ratzz
              Thanks for the ans.
              But i want display different text in the label.
              Is the only way i can do is use different label?
              Like i want to update new information into the label in next line and keep the old info (instead of replace now), can i do it?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @ChrisCl Wouldn't QListView be better for your requirements?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • RatzzR Ratzz

                @ChrisCl
                As above suggested label should be able to show more than one line and set wordWrap with true parameter as show here .

                ChrisClC Offline
                ChrisClC Offline
                ChrisCl
                wrote on last edited by
                #7

                @jsulm
                @Ratzz

                Sorry, i'm new to qt.
                Actually i want to display the console info on my gui, that's why i'm asking this question.
                I did follow the step show on the post but it only display one time info to me.
                For example message->setText("\n123=" + QString::number(8.2f) + "Mfz\n");
                it will only one time of this message.
                But how if i want looping this message and display it 100times and 100 lines on my label, how to do it?

                1 Reply Last reply
                0
                • jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  You can do it like I described above.
                  But you should think whether you're using the right widget?
                  You could use QListView or QPlainTextEdit depending on your requirements. QLabel is usually used for simple labels, not multi line text.
                  What do you mean by "console info"?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • ChrisClC Offline
                    ChrisClC Offline
                    ChrisCl
                    wrote on last edited by
                    #9

                    Hi all,

                    I manage to solve the problem already, by using TextEdit with cursor.

                    message->insertPlainText("Usingdevice"+QString(camera.GetDeviceInfo().GetModelName()));
                    message->moveCursor(QTextCursor::End);
                    message->insertPlainText("123");

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      karti gesar
                      wrote on last edited by
                      #10

                      use for loop to display multiple text with single qlabel

                      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