Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    How to add multiple lines of text from a single class to a scene [SOLVEÐ]

    General and Desktop
    scene print text
    2
    7
    1926
    Loading More Posts
    • 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
      nanoandrew4 last edited by nanoandrew4

      I have been looking around at ways of solving the issue, but haven't found anything yet. What I want is to print speed, altitude, angle, etc... of my plane on the screen, on different lines, but can't manage to print more than one line. Can anyone point to any options I might have to get this done that does not involve creating many classes?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Do you mean a QGraphicsScene ? If so QGraphicsTextItem is probably what you are looking for

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        N 1 Reply Last reply Reply Quote 0
        • N
          nanoandrew4 @SGaist last edited by

          @SGaist Thank you, just found out that I can make it work with pointers, don't know why it didn't work before.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            What do you mean with "with pointers" ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • N
              nanoandrew4 last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • N
                nanoandrew4 last edited by

                What I mean by with pointers is I make QGraphicsTextItem *text1 = new QGraphicsTextItem(); and set the text, font and size and add it to the scene.

                1 Reply Last reply Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  Ok, so what happened before is that the item you added was destroyed before it could be shown

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post